[Frugalware-git] setup: postconf/add_user(): detect if home already
exists
Miklos Vajna
vmiklos at frugalware.org
Tue Mar 3 00:19:26 CET 2009
Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=setup.git;a=commitdiff;h=28c1a34fef6d793184f04e7005f7ab557033f8a3
commit 28c1a34fef6d793184f04e7005f7ab557033f8a3
Author: Miklos Vajna <vmiklos at frugalware.org>
Date: Tue Mar 3 00:17:40 2009 +0100
postconf/add_user(): detect if home already exists
- closes #3339
diff --git a/src/plugins/postconf.c b/src/plugins/postconf.c
index 77dd7e0..b00cf1d 100644
--- a/src/plugins/postconf.c
+++ b/src/plugins/postconf.c
@@ -149,6 +149,8 @@ int add_user()
{
char *login, *fn, *pass, *ptr;
int ret;
+ struct stat buf;
+ char home[PATH_MAX];
if(fw_inputbox(_("Enter login"), _("Please enter the login name you should like to create:"), 0, 0, "", 0) == -1)
return(-1);
@@ -165,7 +167,19 @@ int add_user()
FREE(fn);
return(-1);
}
- ptr = g_strdup_printf("yes ''|chroot ./ /usr/sbin/adduser '%s' \"%s\" '%s'", login, fn, pass);
+ snprintf(home, PATH_MAX, TARGETDIR "/home/%s", login);
+ if(!stat(home, &buf))
+ {
+ ptr = g_strdup_printf(_("'/home/%s' already exists! "
+ "Please change the home directory path to a non-existing directory:"), login);
+ if(fw_inputbox(_("Enter home directory"), ptr, 0, 0, "", 0) == -1)
+ {
+ FREE(ptr);
+ return(-1);
+ }
+ strncpy(home, dialog_vars.input_result, PATH_MAX);
+ }
+ ptr = g_strdup_printf("yes ''|chroot ./ /usr/sbin/adduser '%s' \"%s\" '%s' '%s'", login, fn, pass, home);
ret = fw_system(ptr);
FREE(ptr);
FREE(login);
More information about the Frugalware-git
mailing list