summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/shadow/files
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended/shadow/files')
-rw-r--r--meta/recipes-extended/shadow/files/add_root_cmd_groupmems.patch75
1 files changed, 75 insertions, 0 deletions
diff --git a/meta/recipes-extended/shadow/files/add_root_cmd_groupmems.patch b/meta/recipes-extended/shadow/files/add_root_cmd_groupmems.patch
new file mode 100644
index 0000000000..40444967ab
--- /dev/null
+++ b/meta/recipes-extended/shadow/files/add_root_cmd_groupmems.patch
@@ -0,0 +1,75 @@
1Add a --root command option to groupmems utility.
2
3This option allows the utility to be chrooted when run under pseudo.
4
5Signed-off-by: Mikhail Durnev <mikhail_durnev@mentor.com>
6
7diff -Naur old/src/groupmems.c new/src/groupmems.c
8--- old/src/groupmems.c 2011-02-13 11:58:16.000000000 -0600
9+++ new/src/groupmems.c 2013-05-30 04:45:38.000000000 -0500
10@@ -60,6 +60,7 @@
11 #define EXIT_MEMBER_EXISTS 7 /* member of group already exists */
12 #define EXIT_INVALID_USER 8 /* specified user does not exist */
13 #define EXIT_INVALID_GROUP 9 /* specified group does not exist */
14+#define EXIT_BAD_ARG 10 /* invalid argument to option */
15
16 /*
17 * Global variables
18@@ -79,6 +80,7 @@
19 static bool is_shadowgrp;
20 static bool sgr_locked = false;
21 #endif
22+static const char *newroot = "";
23
24 /* local function prototypes */
25 static char *whoami (void);
26@@ -368,6 +370,7 @@
27 "Options:\n"
28 " -g, --group groupname change groupname instead of the user's group\n"
29 " (root only)\n"
30+ " -R, --root CHROOT_DIR directory to chroot into\n"
31 "\n"
32 "Actions:\n"
33 " -a, --add username add username to the members of the group\n"
34@@ -391,10 +394,11 @@
35 {"group", required_argument, NULL, 'g'},
36 {"list", no_argument, NULL, 'l'},
37 {"purge", no_argument, NULL, 'p'},
38+ {"root", required_argument, NULL, 'R'},
39 {NULL, 0, NULL, '\0'}
40 };
41
42- while ((arg = getopt_long (argc, argv, "a:d:g:lp", long_options,
43+ while ((arg = getopt_long (argc, argv, "a:d:g:lpR:", long_options,
44 &option_index)) != EOF) {
45 switch (arg) {
46 case 'a':
47@@ -416,6 +420,28 @@
48 purge = true;
49 ++exclusive;
50 break;
51+ case 'R':
52+ if ('/' != optarg[0]) {
53+ fprintf (stderr,
54+ _("%s: invalid chroot path '%s'\n"),
55+ Prog, optarg);
56+ exit (EXIT_BAD_ARG);
57+ }
58+ newroot = optarg;
59+
60+ if (access (newroot, F_OK) != 0) {
61+ fprintf(stderr,
62+ _("%s: chroot directory %s does not exist\n"),
63+ Prog, newroot);
64+ exit (EXIT_BAD_ARG);
65+ }
66+ if ( chroot(newroot) != 0 ) {
67+ fprintf(stderr,
68+ _("%s: unable to chroot to directory %s\n"),
69+ Prog, newroot);
70+ exit (EXIT_BAD_ARG);
71+ }
72+ break;
73 default:
74 usage ();
75 }