[Pkg-shadow-devel] Bug#62821: Old proposed patches #1: 462_warn_to_edit_shadow

Nicolas François nicolas.francois at centraliens.net
Tue Jan 10 23:54:56 UTC 2006


On Tue, Jan 10, 2006 at 08:00:36AM +0100, bubulle at debian.org wrote:
> The attached patch was written back in November for Debian bug #62821.
> 
> It simply adds a small warning to vipw reminding the user to also edit
> the shadow file when using either vipw or vigr.
> 
> So far, I haven't got feedback on it.
> 
> I intend to now apply it and close the relevant Debian bug (#62821,
> one of the oldest we have), no matter it's applied upstream or
> not. But, Tomasz, can you give us an indication whether you think it's
> OK for you...

I think it can be applied.

The possible improvements are:
 * also propose to edit the non-shadowed databases when -s is used
 * verify that the system is shadow enabled before the warning
 * Maybe no warning should be displayed in quiet mode?

 * do not just warn, but also propose to edit the other database

The attached patch implements the first two points.
As the message is now displayed 4 times, I prefered to use a generic
message.


-- 
Nekral
-------------- next part --------------
Goal: Warn about possible need to edit shadow files when editing the 
      master files with vipw

Fixes: #62821

Status wrt upstream: Forwarded but not applied yet

Index: shadow-4.0.14/src/vipw.c
===================================================================
--- shadow-4.0.14.orig/src/vipw.c	2005-12-13 15:01:08.000000000 +0100
+++ shadow-4.0.14/src/vipw.c	2006-01-11 00:47:25.000000000 +0100
@@ -41,6 +41,12 @@
 #include "pwio.h"
 #include "sgroupio.h"
 #include "shadowio.h"
+
+#define MSG_WARN_EDIT_OTHER_FILE _( \
+	"You have modified %s.\n"\
+	"You may need to modify %s for consistency.\n"\
+	"Please use the command `%s' to do so.\n")
+
 /*
  * Global variables
  */
@@ -285,17 +291,39 @@
 	}
 
 	if (do_vipw) {
-		if (editshadow)
+		if (editshadow) {
 			vipwedit (SHADOW_FILE, spw_lock, spw_unlock);
-		else
+			printf (MSG_WARN_EDIT_OTHER_FILE,
+			        SHADOW_FILE,
+			        PASSWD_FILE,
+			        "vipw");
+		} else {
 			vipwedit (PASSWD_FILE, pw_lock, pw_unlock);
+			if (spw_file_present ())
+				printf (MSG_WARN_EDIT_OTHER_FILE,
+				        PASSWD_FILE,
+				        SHADOW_FILE,
+				        "vipw -s");
+		}
 	} else {
 #ifdef SHADOWGRP
-		if (editshadow)
+		if (editshadow) {
 			vipwedit (SGROUP_FILE, sgr_lock, sgr_unlock);
-		else
+			printf (MSG_WARN_EDIT_OTHER_FILE,
+			        SGROUP_FILE,
+			        GROUP_FILE,
+			        "vigr");
+		} else {
 #endif
 			vipwedit (GROUP_FILE, gr_lock, gr_unlock);
+#ifdef SHADOWGRP
+			if (sgr_file_present ())
+				printf (MSG_WARN_EDIT_OTHER_FILE,
+				        GROUP_FILE,
+				        SGROUP_FILE,
+				        "vigr -s");
+#endif
+		}
 	}
 
 	nscd_flush_cache ("passwd");


More information about the Pkg-shadow-devel mailing list