summaryrefslogtreecommitdiff
path: root/Users
diff options
context:
space:
mode:
authorcarlosg <carlosg>2006-09-15 16:08:35 +0000
committercarlosg <carlosg>2006-09-15 16:08:35 +0000
commit6aa59e3f48bdf1dc6c89cd0cc1ad3f25a5bfec4c (patch)
treeb24ca6d721a4d5ad16e38f0acd0009888283eb57 /Users
parentf1fb35a04ab2f66c8100cad7d800009d3a36971e (diff)
2006-09-15 Carlos Garnacho <carlosg@gnome.org>
* UsersConfig.pm, GroupsConfig.pm, Users/Users.pm, Users/Groups.pm: add an independent identification number to users and groups, this number should not be modified in the other communication side (GID and UID can be changed) and new users/groups should have different ID numbers (ideally counting from the current max ID number). Fixes the case described in GNOME bug #342293.
Diffstat (limited to 'Users')
-rw-r--r--Users/Groups.pm24
-rw-r--r--Users/Users.pm20
2 files changed, 24 insertions, 20 deletions
diff --git a/Users/Groups.pm b/Users/Groups.pm
index c5e912e..118ad66 100644
--- a/Users/Groups.pm
+++ b/Users/Groups.pm
@@ -25,10 +25,10 @@
package Users::Groups;
# enum like for verbose group array positions
-my $LOGIN = 0;
-my $PASSWD = 1;
-my $GID = 2;
-my $USERS = 3;
+my $LOGIN = 1;
+my $PASSWD = 2;
+my $GID = 3;
+my $USERS = 4;
# quite generic data
$group_names = "/etc/group";
@@ -166,10 +166,9 @@ sub change_group
sub get
{
my ($ifh, @groups, $group_last_modified);
- my (@line, $copy, @a);
-
- # Find the file.
+ my (@line, $copy, @a, $counter);
+ $counter = 1;
$ifh = &Utils::File::open_read_from_names($group_names);
return unless ($ifh);
@@ -182,13 +181,14 @@ sub get
# FreeBSD allows comments in the group file. */
next if &Utils::Util::ignore_line ($_);
- $_ = &Utils::XML::unquote ($_);
@line = split ':', $_, -1;
+ unshift @line, $counter;
@a = split ',', pop @line;
push @line, [@a];
$copy = [@line];
push (@groups, $copy);
+ $counter++;
}
&Utils::File::close_file ($ifh);
@@ -219,14 +219,14 @@ sub set
foreach $i (@$config)
{
- $groups{$$i[$LOGIN]} |= 1;
- $config_hash{$$i[$LOGIN]} = $i;
+ $groups{$$i[0]} |= 1;
+ $config_hash{$$i[0]} = $i;
}
foreach $i (@$old_config)
{
- $groups{$$i[$LOGIN]} |= 2;
- $old_config_hash{$$i[$LOGIN]} = $i;
+ $groups{$$i[0]} |= 2;
+ $old_config_hash{$$i[0]} = $i;
}
# Delete all groups that only appeared in the old configuration
diff --git a/Users/Users.pm b/Users/Users.pm
index 304f1cb..edf6c98 100644
--- a/Users/Users.pm
+++ b/Users/Users.pm
@@ -73,13 +73,14 @@ $cmd_chfn = &Utils::File::locate_tool ("chfn");
$cmd_pw = &Utils::File::locate_tool ("pw");
# enum like for verbose group array positions
-my $LOGIN = 0;
-my $PASSWD = 1;
-my $UID = 2;
-my $GID = 3;
-my $COMMENT = 4;
-my $HOME = 5;
-my $SHELL = 6;
+my $ID = 0;
+my $LOGIN = 1;
+my $PASSWD = 2;
+my $UID = 3;
+my $GID = 4;
+my $COMMENT = 5;
+my $HOME = 6;
+my $SHELL = 7;
%login_defs_prop_map = ();
%profiles_prop_map = ();
@@ -373,9 +374,10 @@ sub get_logindefs
sub get
{
my ($ifh, @users, %users_hash);
- my (@line, @users);
+ my (@line, @users, $counter);
# Find the passwd file.
+ $counter = 1;
$ifh = &Utils::File::open_read_from_names(@passwd_names);
return unless ($ifh);
@@ -386,6 +388,8 @@ sub get
next if &Utils::Util::ignore_line ($_);
@line = split ':', $_, -1;
+ unshift @line, $counter;
+ $counter++;
$login = $line[$LOGIN];
@comment = split ',', $line[$COMMENT], 5;