diff options
author | Thomas Osterried <thomas@osterried.de> | 2006-12-10 16:44:39 +0000 |
---|---|---|
committer | Thomas Osterried <thomas@osterried.de> | 2006-12-10 16:44:39 +0000 |
commit | a824b0ba5e756660406a8a4648f60692a5cdce30 (patch) | |
tree | 5e89232c91ccc058eccdcdea917342c18cdc3883 /ax25/axspawn.c | |
parent | 09381d03c64020b0900c7cc0ae22d35a7d476497 (diff) |
useradd now with "-s shell" option under special circumstances
Diffstat (limited to 'ax25/axspawn.c')
-rw-r--r-- | ax25/axspawn.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/ax25/axspawn.c b/ax25/axspawn.c index bb2dc7a..4345025 100644 --- a/ax25/axspawn.c +++ b/ax25/axspawn.c @@ -1,6 +1,6 @@ /* * - * $Id: axspawn.c,v 1.8 2006/06/10 19:12:46 dl9sau Exp $ + * $Id: axspawn.c,v 1.9 2006/12/10 16:44:39 dl9sau Exp $ * * axspawn.c - run a program from ax25d. * @@ -205,6 +205,8 @@ #define EXITDELAY 10 +#define USERADD_CONF "/etc/default/useradd" + struct huffencodtab { unsigned short code; unsigned short len; @@ -1110,9 +1112,23 @@ retry: */ if (policy_add_prog_useradd) { - sprintf(command,"/usr/sbin/useradd -p \"%s\" -c %s -d %s -u %d -g %d -m %s", + char *opt_shell = ""; + struct stat statbuf; + if (stat(USERADD_CONF, &statbuf) == -1) { + /* some programs need a shell explicitely specified + * in /etc/passwd, although this field is not required + * (and useradd does not set a shell when not + * specified). + * useradd has a config file. On debian for e.g., + * there is no /etc/default/useradd. Thus we + * explecitely give the shell option to useradd, when + * no useradd config file is present. + */ + opt_shell = " -s \"/bin/sh\""; + } + sprintf(command,"/usr/sbin/useradd -p \"%s\" -c %s -d %s -u %d -g %d -m %s%s", ((policy_add_empty_password) ? "" : "+"), - username, userdir, uid, user_gid, newuser); + username, userdir, uid, user_gid, newuser, opt_shell); if (system(command) != 0) goto out; } else { |