[Pkg-shadow-commits] r1646 - in upstream/trunk: . src

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Sat Jan 5 14:17:43 UTC 2008


Author: nekral-guest
Date: 2008-01-05 14:17:43 +0000 (Sat, 05 Jan 2008)
New Revision: 1646

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/NEWS
   upstream/trunk/src/groupadd.c
   upstream/trunk/src/groupmod.c
Log:
Add option --password to groupadd and groupmod (similar to useradd and usermod).


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-01-05 14:09:56 UTC (rev 1645)
+++ upstream/trunk/ChangeLog	2008-01-05 14:17:43 UTC (rev 1646)
@@ -1,5 +1,10 @@
 2008-01-05  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* NEWS, src/groupmod.c, src/groupadd.c: Add option --password to
+	groupadd and groupmod (similar to useradd and usermod).
+
+2008-01-05  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* lib/prototypes.h: grent.c does not exist anymore. Remove the
 	putgrent prototype.
 	* lib/prototypes.h: "shadowio.h" was included for the definition

Modified: upstream/trunk/NEWS
===================================================================
--- upstream/trunk/NEWS	2008-01-05 14:09:56 UTC (rev 1645)
+++ upstream/trunk/NEWS	2008-01-05 14:17:43 UTC (rev 1646)
@@ -8,6 +8,10 @@
 - chage
   * Fix bug which forbid to set the aging information of an account with a
     passwd entry, but no shadow entry.
+- groupadd
+  * New option -p/--password to specify an encrypted password.
+- groupmod
+  * New option -p/--password to specify an encrypted password.
 - grpck
   * Fix logging of changes to syslog when a group file is provided,
     without a gshadow file.

Modified: upstream/trunk/src/groupadd.c
===================================================================
--- upstream/trunk/src/groupadd.c	2008-01-05 14:09:56 UTC (rev 1645)
+++ upstream/trunk/src/groupadd.c	2008-01-05 14:17:43 UTC (rev 1646)
@@ -68,6 +68,7 @@
  */
 static char *group_name;
 static gid_t group_id;
+static char *group_passwd;
 static char *empty_list = NULL;
 
 static char *Prog;
@@ -75,6 +76,7 @@
 static int oflg = 0;		/* permit non-unique group ID to be specified with -g */
 static int gflg = 0;		/* ID value for the new group */
 static int fflg = 0;		/* if group already exists, do nothing and exit(0) */
+static int pflg = 0;		/* new encrypted password */
 
 #ifdef USE_PAM
 static pam_handle_t *pamh = NULL;
@@ -127,7 +129,11 @@
 {
 	memzero (grent, sizeof *grent);
 	grent->gr_name = group_name;
-	grent->gr_passwd = SHADOW_PASSWD_STRING;	/* XXX warning: const */
+	if (pflg) {
+		grent->gr_passwd = group_passwd;
+	} else {
+		grent->gr_passwd = SHADOW_PASSWD_STRING;	/* XXX warning: const */
+	}
 	grent->gr_gid = group_id;
 	grent->gr_mem = &empty_list;
 }
@@ -143,7 +149,11 @@
 {
 	memzero (sgent, sizeof *sgent);
 	sgent->sg_name = group_name;
-	sgent->sg_passwd = "!";	/* XXX warning: const */
+	if (pflg) {
+		sgent->sg_passwd = group_passwd;
+	} else {
+		sgent->sg_passwd = "!";	/* XXX warning: const */
+	}
 	sgent->sg_adm = &empty_list;
 	sgent->sg_mem = &empty_list;
 }
@@ -168,6 +178,9 @@
 	new_grent (&grp);
 #ifdef	SHADOWGRP
 	new_sgent (&sgrp);
+	if (is_shadow_grp && pflg) {
+		grent->gr_passwd = SHADOW_PASSWD_STRING;	/* XXX warning: const */
+	}
 #endif				/* SHADOWGRP */
 
 	/*
@@ -393,6 +406,7 @@
 		{"help", no_argument, NULL, 'h'},
 		{"key", required_argument, NULL, 'K'},
 		{"non-unique", required_argument, NULL, 'o'},
+		{"password", required_argument, NULL, 'p'},
 		{NULL, 0, NULL, '\0'}
 	};
 
@@ -440,6 +454,10 @@
 		case 'o':
 			oflg++;
 			break;
+		case 'p':
+			pglf++;
+			group_passwd = optarg;
+			break;
 		default:
 			usage ();
 		}

Modified: upstream/trunk/src/groupmod.c
===================================================================
--- upstream/trunk/src/groupmod.c	2008-01-05 14:09:56 UTC (rev 1645)
+++ upstream/trunk/src/groupmod.c	2008-01-05 14:17:43 UTC (rev 1646)
@@ -67,6 +67,7 @@
 #endif
 static char *group_name;
 static char *group_newname;
+static char *group_passwd;
 static gid_t group_id;
 static gid_t group_newid;
 
@@ -75,7 +76,8 @@
 static int
     oflg = 0,			/* permit non-unique group ID to be specified with -g */
     gflg = 0,			/* new ID value for the group */
-    nflg = 0;			/* a new name has been specified for the group */
+    nflg = 0,			/* a new name has been specified for the group */
+    pflg = 0;			/* new encrypted password */
 
 /* local function prototypes */
 static void usage (void);
@@ -105,6 +107,7 @@
 			   "  -h, --help                    display this help message and exit\n"
 			   "  -n, --new-name NEW_GROUP      force use NEW_GROUP name by GROUP\n"
 			   "  -o, --non-unique              allow using duplicate (non-unique) GID by GROUP\n"
+			   "  -p, --password PASSWORD       use encrypted password for the new password\n"
 			   "\n"));
 	exit (E_USAGE);
 }
@@ -122,6 +125,9 @@
 
 	if (gflg)
 		grent->gr_gid = group_newid;
+
+	if (pflg)
+		grent->gr_passwd = group_passwd;
 }
 
 #ifdef	SHADOWGRP
@@ -135,6 +141,9 @@
 {
 	if (nflg)
 		sgent->sg_name = xstrdup (group_newname);
+
+	if (pflg)
+		sgent->sg_passwd = group_passwd;
 }
 #endif				/* SHADOWGRP */
 
@@ -173,6 +182,8 @@
 	if (is_shadow_grp && (osgrp = sgr_locate (group_name))) {
 		sgrp = *osgrp;
 		new_sgent (&sgrp);
+		if (pflg)
+			grp.gr_passwd = SHADOW_PASSWD_STRING;
 	}
 #endif				/* SHADOWGRP */
 
@@ -208,7 +219,7 @@
 	/*
 	 * Write out the new shadow group entries as well.
 	 */
-	if (!sgr_update (&sgrp)) {
+	if (is_shadow_grp && !sgr_update (&sgrp)) {
 		fprintf (stderr, _("%s: error adding new group entry\n"), Prog);
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding group",
@@ -216,7 +227,7 @@
 #endif
 		exit (E_GRP_UPDATE);
 	}
-	if (nflg && !sgr_remove (group_name)) {
+	if (is_shadow_grp && nflg && !sgr_remove (group_name)) {
 		fprintf (stderr, _("%s: error removing group entry\n"), Prog);
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "deleting group",
@@ -354,6 +365,7 @@
 			{"help", no_argument, NULL, 'h'},
 			{"new-name", required_argument, NULL, 'n'},
 			{"non-unique", no_argument, NULL, 'o'},
+			{"password", required_argument, NULL, 'p'},
 			{NULL, 0, NULL, '\0'}
 		};
 		while ((c =
@@ -376,6 +388,10 @@
 			case 'o':
 				oflg++;
 				break;
+			case 'p':
+				group_passwd = optarg;
+				pflg++;
+				break;
 			default:
 				usage ();
 			}




More information about the Pkg-shadow-commits mailing list