Tizen 2.1 base
[external/shadow-utils.git] / packaging / 428_grpck_add_prune_option
1 Goal: grpck now has an (otherwise undocumented) -p option, so that
2       shadowconfig can clean up the results of the above, so the config
3       script will fail randomly less often.
4 Fixes: #103385
5
6 Status wrt upstream: It could certainly be submitted to upstream.
7
8 --- a/src/grpck.c
9 +++ b/src/grpck.c
10 @@ -79,6 +79,7 @@
11  /* Options */
12  static bool read_only = false;
13  static bool sort_mode = false;
14 +static bool prune = false;
15  
16  /* local function prototypes */
17  static void fail_exit (int status);
18 @@ -178,7 +179,7 @@
19         /*
20          * Parse the command line arguments
21          */
22 -       while ((arg = getopt (argc, argv, "qrs")) != EOF) {
23 +       while ((arg = getopt (argc, argv, "qprs")) != EOF) {
24                 switch (arg) {
25                 case 'q':
26                         /* quiet - ignored for now */
27 @@ -189,6 +190,9 @@
28                 case 's':
29                         sort_mode = true;
30                         break;
31 +               case 'p':
32 +                       prune = true;
33 +                       break;
34                 default:
35                         usage ();
36                 }
37 @@ -474,7 +478,12 @@
38                         /*
39                          * prompt the user to delete the entry or not
40                          */
41 -                       if (!yes_or_no (read_only)) {
42 +                       if (!prune) {
43 +                               if (!yes_or_no (read_only)) {
44 +                                       continue;
45 +                               }
46 +                       } else {
47 +                               puts (_("Yes"));
48                                 continue;
49                         }
50