a few corrections
This commit is contained in:
+18
-15
@@ -1,19 +1,19 @@
|
|||||||
--- loginutils/adduser.c.orig
|
--- loginutils/adduser.c.orig
|
||||||
+++ loginutils/adduser.c
|
+++ loginutils/adduser.c
|
||||||
@@ -44,6 +44,7 @@
|
@@ -44,6 +44,7 @@
|
||||||
//usage: "\n -H Don't create home directory"
|
//usage: "\n\t-H\t\tDon't create home directory"
|
||||||
//usage: "\n -u UID User id"
|
//usage: "\n\t-u UID\t\tUser id"
|
||||||
//usage: "\n -k SKEL Skeleton directory (/etc/skel)"
|
//usage: "\n\t-k SKEL\t\tSkeleton directory (/etc/skel)"
|
||||||
+//usage: "\n -b DOB Date of birth (YYYYMMDD)"
|
+//usage: "\n\t-b DOB\t\tDate of birth (YYYYMMDD)"
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
@@ -61,6 +62,7 @@
|
@@ -61,6 +62,7 @@
|
||||||
#define OPT_DONT_MAKE_HOME (1 << 6)
|
#define OPT_DONT_MAKE_HOME (1 << 6)
|
||||||
#define OPT_UID (1 << 7)
|
#define OPT_UID (1 << 7)
|
||||||
#define OPT_SKEL (1 << 8)
|
#define OPT_SKEL (1 << 8)
|
||||||
+#define OPT_DOB (1 << 9)
|
+#define OPT_DOB (1 << 9)
|
||||||
|
|
||||||
/* remix */
|
/* remix */
|
||||||
/* recoded such that the uid may be passed in *p */
|
/* recoded such that the uid may be passed in *p */
|
||||||
@@ -128,6 +130,7 @@
|
@@ -128,6 +130,7 @@
|
||||||
@@ -22,36 +22,38 @@
|
|||||||
"skel\0" Required_argument "k"
|
"skel\0" Required_argument "k"
|
||||||
+ "dob\0" Required_argument "b"
|
+ "dob\0" Required_argument "b"
|
||||||
;
|
;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -141,6 +144,7 @@
|
@@ -141,6 +144,7 @@
|
||||||
unsigned opts;
|
unsigned opts;
|
||||||
char *uid;
|
char *uid;
|
||||||
const char *skel = "/etc/skel";
|
const char *skel = "/etc/skel";
|
||||||
+ char *dob = NULL;
|
+ char *dob = NULL;
|
||||||
|
|
||||||
/* got root? */
|
/* got root? */
|
||||||
if (geteuid()) {
|
if (geteuid()) {
|
||||||
@@ -151,12 +155,12 @@
|
@@ -151,7 +155,7 @@
|
||||||
pw.pw_dir = NULL;
|
pw.pw_dir = NULL;
|
||||||
|
|
||||||
opts = getopt32long(argv, "^"
|
opts = getopt32long(argv, "^"
|
||||||
- "h:g:s:G:DSHu:k:"
|
- "h:g:s:G:DSHu:k:"
|
||||||
+ "h:g:s:G:DSHu:k:b:"
|
+ "h:g:s:G:DSHu:k:b:"
|
||||||
/* at least one and at most two non-option args */
|
/* at least one and at most two non-option args */
|
||||||
/* disable interactive passwd for system accounts */
|
/* disable interactive passwd for system accounts */
|
||||||
"\0" "-1:?2:SD",
|
"\0" "-1:?2:SD",
|
||||||
|
@@ -158,7 +162,7 @@
|
||||||
adduser_longopts,
|
adduser_longopts,
|
||||||
|
&pw.pw_dir, &pw.pw_gecos, &pw.pw_shell,
|
||||||
|
&usegroup, &uid, &skel
|
||||||
- &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell,
|
- &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell,
|
||||||
- &usegroup, &uid, &skel
|
|
||||||
+ &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell,
|
|
||||||
+ &usegroup, &uid, &skel, &dob
|
+ &usegroup, &uid, &skel, &dob
|
||||||
);
|
);
|
||||||
if (opts & OPT_UID)
|
if (opts & OPT_UID)
|
||||||
|
pw.pw_uid = atoi(uid);
|
||||||
@@ -200,6 +204,16 @@
|
@@ -200,6 +204,16 @@
|
||||||
free(p);
|
free(p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+ /* Record date of birth if specified */
|
+ /* Record date of birth if specified */
|
||||||
+ if (opts & OPT_DOB) {
|
+ if (opts & OPT_DOB) {
|
||||||
+ FILE *f = fopen("/etc/birthdays", "a");
|
+ FILE *f = fopen("/etc/birthdays", "a");
|
||||||
@@ -62,6 +64,7 @@
|
|||||||
+ bb_perror_msg("/etc/birthdays");
|
+ bb_perror_msg("/etc/birthdays");
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
/* add to group */
|
/* add to group */
|
||||||
addgroup_wrapper(&pw, usegroup);
|
addgroup_wrapper(&pw, usegroup);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user