summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended
diff options
context:
space:
mode:
authorMikhail Durnev <mikhail_durnev@mentor.com>2013-06-25 21:54:35 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-28 09:14:07 +0100
commit1f7647c197929f5a8c633a93a02ac9f04b94b3ae (patch)
treee1cd5fa8cef808b23a04ea8babe52b3e4f8d4d56 /meta/recipes-extended
parentb50d97cb4a5a950c39cfe395a28bd6071cfd15fb (diff)
downloadpoky-1f7647c197929f5a8c633a93a02ac9f04b94b3ae.tar.gz
shadow-native: Add --root option in groupmems
Patch add_root_cmd_groupmems.patch that we apply to shadow-native allows program groupmems from the shadow utility package to chroot() so it can be used to modify etc/passwd and etc/group if they are located in a sysroot. The --root option in groupmems is needed for class useradd. (From OE-Core rev: ae7aa0ef68372c15224c0c518cb90ba7350137b4) Signed-off-by: Mikhail Durnev <mikhail_durnev@mentor.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended')
-rw-r--r--meta/recipes-extended/shadow/files/add_root_cmd_groupmems.patch75
-rw-r--r--meta/recipes-extended/shadow/shadow-native_4.1.4.3.bb1
2 files changed, 76 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 }
diff --git a/meta/recipes-extended/shadow/shadow-native_4.1.4.3.bb b/meta/recipes-extended/shadow/shadow-native_4.1.4.3.bb
index 2c4edbef0e..1ed5d4e011 100644
--- a/meta/recipes-extended/shadow/shadow-native_4.1.4.3.bb
+++ b/meta/recipes-extended/shadow/shadow-native_4.1.4.3.bb
@@ -17,6 +17,7 @@ SRC_URI = "http://pkg-shadow.alioth.debian.org/releases/${BPN}-${PV}.tar.bz2 \
17 file://disable-syslog.patch \ 17 file://disable-syslog.patch \
18 file://useradd.patch \ 18 file://useradd.patch \
19 file://shadow_fix_for_automake-1.12.patch \ 19 file://shadow_fix_for_automake-1.12.patch \
20 file://add_root_cmd_groupmems.patch \
20 " 21 "
21 22
22SRC_URI[md5sum] = "b8608d8294ac88974f27b20f991c0e79" 23SRC_URI[md5sum] = "b8608d8294ac88974f27b20f991c0e79"