/[smeserver]/rpms/e-smith-lib/sme9/e-smith-lib-2.4.0-CreateSystemUser.patch
ViewVC logotype

Contents of /rpms/e-smith-lib/sme9/e-smith-lib-2.4.0-CreateSystemUser.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue May 7 15:07:42 2013 UTC (11 years ago) by wellsi
Branch: MAIN
CVS Tags: e-smith-lib-2_4_0-18_el6_sme, e-smith-lib-2_4_0-9_el6_sme, e-smith-lib-2_4_0-11_el6_sme, e-smith-lib-2_4_0-12_el6_sme, e-smith-lib-2_4_0-17_el6_sme, e-smith-lib-2_4_0-15_el6_sme, e-smith-lib-2_4_0-16_el6_sme, e-smith-lib-2_4_0-13_el6_sme, e-smith-lib-2_4_0-14_el6_sme, e-smith-lib-2_4_0-8_el6_sme, e-smith-lib-2_4_0-10_el6_sme, HEAD
* Sun May 05 2013 Ian Wells <esmith@wellsi.com> 2.4.0-8.sme
- Add e-smith as a prereq to enable removal of adding users in %pre [SME: 7547]

1 diff -ruN e-smith-lib-2.4.0.old/root/sbin/e-smith/create-system-user e-smith-lib-2.4.0/root/sbin/e-smith/create-system-user
2 --- e-smith-lib-2.4.0.old/root/sbin/e-smith/create-system-user 2003-09-02 14:05:26.000000000 -0700
3 +++ e-smith-lib-2.4.0/root/sbin/e-smith/create-system-user 2013-05-05 22:22:42.000000000 -0700
4 @@ -20,7 +20,6 @@
5 my $user_desc = shift || usage("Must give user desc param");
6 my $home = shift || usage("Must give home param");
7 my $shell = shift || usage("Must give shell param");
8 -my @uid_opts = ("-u", $uid);
9
10 use User::pwent;
11 use User::grent;
12 @@ -28,7 +27,7 @@
13 if (my $pw = getpwnam($user))
14 {
15 my $euid = $pw->uid;
16 - exit 0 if $euid == $uid;
17 + exit 0 if $euid == $uid; # Do not create user if it already exists with correct uid
18 warn ("Users $user exists but has uid of $euid - should be $uid\n");
19 exit 0;
20 }
21 @@ -38,23 +37,48 @@
22 my $name = $pw->name;
23 warn "User id of $uid is already taken by user $name\n";
24 warn "Falling back to a system chosen uid\n";
25 - @uid_opts = ("-r");
26 + # We can now go ahead and create the user and group leaving the system to choose uid/gid
27 + die ("Failed to create user $user\n") if
28 + system("/usr/sbin/useradd",
29 + "-r",
30 + "-d", $home,
31 + "-M",
32 + "-s", $shell,
33 + "-c", $user_desc,
34 + $user);
35 + exit (0);
36 }
37
38 if (my $pw = getgrgid($uid))
39 {
40 my $name = $pw->name;
41 warn "Group id of $uid is already taken by user $name\n";
42 + # We can now go ahead and create the user but the gid will be chosen by the system
43 + die ("Failed to create user $user\n") if
44 + system("/usr/sbin/useradd",
45 + "-u", $uid,
46 + "-d", $home,
47 + "-M",
48 + "-s", $shell,
49 + "-c", $user_desc,
50 + $user);
51 }
52 -
53 +else
54 +{
55 # We can now go ahead and create the user and group
56 -
57 -die("Failed to create user $user\n") if
58 - system("/usr/sbin/useradd",
59 - @uid_opts,
60 - "-d", $home,
61 - "-M",
62 - "-s", $shell,
63 - "-c", $user_desc,
64 - $user);
65 + die ("Failed to create group $uid\n") if
66 + system("/usr/sbin/groupadd",
67 + "-g", $uid,
68 + $user);
69 +
70 + die ("Failed to create user $user\n") if
71 + system("/usr/sbin/useradd",
72 + "-u", $uid,
73 + "-g", $uid,
74 + "-d", $home,
75 + "-M",
76 + "-s", $shell,
77 + "-c", $user_desc,
78 + $user);
79 +}
80 exit 0;

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed