* src/useradd.c: Re-indent.
This commit is contained in:
parent
06c81b67c2
commit
95bc6eb7b2
@ -1,5 +1,6 @@
|
|||||||
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/useradd.c: Re-indent.
|
||||||
* src/useradd.c: Use getlong instead of get_number.
|
* src/useradd.c: Use getlong instead of get_number.
|
||||||
|
|
||||||
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
@ -443,14 +443,16 @@ static int set_defaults (void)
|
|||||||
ofd = mkstemp (new_file);
|
ofd = mkstemp (new_file);
|
||||||
if (-1 == ofd) {
|
if (-1 == ofd) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: cannot create new defaults file\n"), Prog);
|
_("%s: cannot create new defaults file\n"),
|
||||||
|
Prog);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ofp = fdopen (ofd, "w");
|
ofp = fdopen (ofd, "w");
|
||||||
if (NULL == ofp) {
|
if (NULL == ofp) {
|
||||||
fprintf (stderr, _("%s: cannot open new defaults file\n"),
|
fprintf (stderr,
|
||||||
Prog);
|
_("%s: cannot open new defaults file\n"),
|
||||||
|
Prog);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,8 +493,9 @@ static int set_defaults (void)
|
|||||||
out_skel = true;
|
out_skel = true;
|
||||||
} else if (!out_create_mail_spool
|
} else if (!out_create_mail_spool
|
||||||
&& MATCH (buf, CREATE_MAIL_SPOOL)) {
|
&& MATCH (buf, CREATE_MAIL_SPOOL)) {
|
||||||
fprintf (ofp, CREATE_MAIL_SPOOL "%s\n",
|
fprintf (ofp,
|
||||||
def_create_mail_spool);
|
CREATE_MAIL_SPOOL "%s\n",
|
||||||
|
def_create_mail_spool);
|
||||||
out_create_mail_spool = true;
|
out_create_mail_spool = true;
|
||||||
} else
|
} else
|
||||||
fprintf (ofp, "%s\n", buf);
|
fprintf (ofp, "%s\n", buf);
|
||||||
@ -559,11 +562,11 @@ static int set_defaults (void)
|
|||||||
SHADOW_AUDIT_SUCCESS);
|
SHADOW_AUDIT_SUCCESS);
|
||||||
#endif
|
#endif
|
||||||
SYSLOG ((LOG_INFO,
|
SYSLOG ((LOG_INFO,
|
||||||
"useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, "
|
"useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, "
|
||||||
"EXPIRE=%s, SKEL=%s, CREATE_MAIL_SPOOL=%s",
|
"EXPIRE=%s, SKEL=%s, CREATE_MAIL_SPOOL=%s",
|
||||||
(unsigned int) def_group, def_home, def_shell,
|
(unsigned int) def_group, def_home, def_shell,
|
||||||
def_inactive, def_expire, def_template,
|
def_inactive, def_expire, def_template,
|
||||||
def_create_mail_spool));
|
def_create_mail_spool));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,8 +613,9 @@ static int get_groups (char *list)
|
|||||||
* string name.
|
* string name.
|
||||||
*/
|
*/
|
||||||
if (NULL == grp) {
|
if (NULL == grp) {
|
||||||
fprintf (stderr, _("%s: group '%s' does not exist\n"),
|
fprintf (stderr,
|
||||||
Prog, list);
|
_("%s: group '%s' does not exist\n"),
|
||||||
|
Prog, list);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
list = cp;
|
list = cp;
|
||||||
@ -631,17 +635,16 @@ static int get_groups (char *list)
|
|||||||
*/
|
*/
|
||||||
if (__isgrNIS ()) {
|
if (__isgrNIS ()) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: group '%s' is a NIS group.\n"),
|
_("%s: group '%s' is a NIS group.\n"),
|
||||||
Prog, grp->gr_name);
|
Prog, grp->gr_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ngroups == sys_ngroups) {
|
if (ngroups == sys_ngroups) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_
|
_("%s: too many groups specified (max %d).\n"),
|
||||||
("%s: too many groups specified (max %d).\n"),
|
Prog, ngroups);
|
||||||
Prog, ngroups);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -848,8 +851,9 @@ static void grp_update (void)
|
|||||||
user_name, AUDIT_NO_ID,
|
user_name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_SUCCESS);
|
SHADOW_AUDIT_SUCCESS);
|
||||||
#endif
|
#endif
|
||||||
SYSLOG ((LOG_INFO, "add '%s' to group '%s'",
|
SYSLOG ((LOG_INFO,
|
||||||
user_name, ngrp->gr_name));
|
"add '%s' to group '%s'",
|
||||||
|
user_name, ngrp->gr_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
@ -882,8 +886,8 @@ static void grp_update (void)
|
|||||||
nsgrp = __sgr_dup (sgrp);
|
nsgrp = __sgr_dup (sgrp);
|
||||||
if (NULL == nsgrp) {
|
if (NULL == nsgrp) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: Out of memory. Cannot update %s.\n"),
|
_("%s: Out of memory. Cannot update %s.\n"),
|
||||||
Prog, sgr_dbname ());
|
Prog, sgr_dbname ());
|
||||||
SYSLOG ((LOG_ERR, "failed to prepare the new %s entry '%s'", sgr_dbname (), user_name));
|
SYSLOG ((LOG_ERR, "failed to prepare the new %s entry '%s'", sgr_dbname (), user_name));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_ADD_USER, Prog,
|
audit_logger (AUDIT_ADD_USER, Prog,
|
||||||
@ -918,8 +922,9 @@ static void grp_update (void)
|
|||||||
user_name, AUDIT_NO_ID,
|
user_name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_SUCCESS);
|
SHADOW_AUDIT_SUCCESS);
|
||||||
#endif
|
#endif
|
||||||
SYSLOG ((LOG_INFO, "add '%s' to shadow group '%s'",
|
SYSLOG ((LOG_INFO,
|
||||||
user_name, nsgrp->sg_name));
|
"add '%s' to shadow group '%s'",
|
||||||
|
user_name, nsgrp->sg_name));
|
||||||
}
|
}
|
||||||
#endif /* SHADOWGRP */
|
#endif /* SHADOWGRP */
|
||||||
}
|
}
|
||||||
@ -1060,7 +1065,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
if (NULL == grp) {
|
if (NULL == grp) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: group '%s' does not exist\n"),
|
_("%s: group '%s' does not exist\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
exit (E_NOTFOUND);
|
exit (E_NOTFOUND);
|
||||||
}
|
}
|
||||||
if (Dflg) {
|
if (Dflg) {
|
||||||
@ -1263,8 +1268,8 @@ static void process_flags (int argc, char **argv)
|
|||||||
create_mail_spool = def_create_mail_spool;
|
create_mail_spool = def_create_mail_spool;
|
||||||
|
|
||||||
if (!rflg) {
|
if (!rflg) {
|
||||||
/* for system accounts defaults are ignored and we
|
/* for system accounts defaults are ignored and we
|
||||||
* do not create a home dir */
|
* do not create a home dir */
|
||||||
if (getdef_bool("CREATE_HOME")) {
|
if (getdef_bool("CREATE_HOME")) {
|
||||||
mflg = true;
|
mflg = true;
|
||||||
}
|
}
|
||||||
@ -1611,9 +1616,9 @@ static void usr_update (void)
|
|||||||
* happens so we know what we were trying to accomplish.
|
* happens so we know what we were trying to accomplish.
|
||||||
*/
|
*/
|
||||||
SYSLOG ((LOG_INFO,
|
SYSLOG ((LOG_INFO,
|
||||||
"new user: name=%s, UID=%u, GID=%u, home=%s, shell=%s",
|
"new user: name=%s, UID=%u, GID=%u, home=%s, shell=%s",
|
||||||
user_name, (unsigned int) user_id,
|
user_name, (unsigned int) user_id,
|
||||||
(unsigned int) user_gid, user_home, user_shell));
|
(unsigned int) user_gid, user_home, user_shell));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize faillog and lastlog entries for this UID in case
|
* Initialize faillog and lastlog entries for this UID in case
|
||||||
@ -1680,9 +1685,8 @@ static void create_home (void)
|
|||||||
/* XXX - create missing parent directories. --marekm */
|
/* XXX - create missing parent directories. --marekm */
|
||||||
if (mkdir (user_home, 0) != 0) {
|
if (mkdir (user_home, 0) != 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_
|
_("%s: cannot create directory %s\n"),
|
||||||
("%s: cannot create directory %s\n"),
|
Prog, user_home);
|
||||||
Prog, user_home);
|
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_ADD_USER, Prog,
|
audit_logger (AUDIT_ADD_USER, Prog,
|
||||||
"adding home directory",
|
"adding home directory",
|
||||||
@ -1867,8 +1871,8 @@ int main (int argc, char **argv)
|
|||||||
/* local, no need for xgetgrnam */
|
/* local, no need for xgetgrnam */
|
||||||
if (getgrnam (user_name) != NULL) {
|
if (getgrnam (user_name) != NULL) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: group %s exists - if you want to add this user to that group, use -g.\n"),
|
_("%s: group %s exists - if you want to add this user to that group, use -g.\n"),
|
||||||
Prog, user_name);
|
Prog, user_name);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_ADD_USER, Prog,
|
audit_logger (AUDIT_ADD_USER, Prog,
|
||||||
"adding group",
|
"adding group",
|
||||||
@ -1920,8 +1924,8 @@ int main (int argc, char **argv)
|
|||||||
if (Uflg) {
|
if (Uflg) {
|
||||||
if (find_new_gid (rflg, &user_gid, &user_id) < 0) {
|
if (find_new_gid (rflg, &user_gid, &user_id) < 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: can't create group\n"),
|
_("%s: can't create group\n"),
|
||||||
Prog);
|
Prog);
|
||||||
fail_exit (4);
|
fail_exit (4);
|
||||||
}
|
}
|
||||||
grp_add ();
|
grp_add ();
|
||||||
@ -1931,14 +1935,14 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
if (mflg) {
|
if (mflg) {
|
||||||
create_home ();
|
create_home ();
|
||||||
if (home_added)
|
if (home_added) {
|
||||||
copy_tree (def_template, user_home, user_id, user_gid);
|
copy_tree (def_template, user_home, user_id, user_gid);
|
||||||
else
|
} else {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_
|
_("%s: warning: the home directory already exists.\n"
|
||||||
("%s: warning: the home directory already exists.\n"
|
"Not copying any file from skel directory into it.\n"),
|
||||||
"Not copying any file from skel directory into it.\n"),
|
Prog);
|
||||||
Prog);
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user