summaryrefslogtreecommitdiff
path: root/Users
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2007-11-08 00:04:35 +0100
committerCarlos Garnacho <carlosg@gnome.org>2007-11-08 00:04:35 +0100
commitc1a794f2a3acfb74f6693fc36f74fa3593656926 (patch)
treed4b107d127cc43fa53edc3dc21f94fcbc6da125b /Users
parent4d48931dde999ca67bb8d08acecfc2e2b6b27964 (diff)
Do the same to GroupsConfig. Also, remove the ID from the message format.
This is a interface change, but a few more are to come in order to become more maintenable in the future, and the adoption of s-t-b is still low enough.
Diffstat (limited to 'Users')
-rw-r--r--Users/Groups.pm28
-rw-r--r--Users/Users.pm22
2 files changed, 22 insertions, 28 deletions
diff --git a/Users/Groups.pm b/Users/Groups.pm
index 8b13f00..c19053f 100644
--- a/Users/Groups.pm
+++ b/Users/Groups.pm
@@ -25,10 +25,11 @@
package Users::Groups;
# enum like for verbose group array positions
-my $LOGIN = 1;
-my $PASSWD = 2;
-my $GID = 3;
-my $USERS = 4;
+my $i = 0;
+my $LOGIN = $i++;
+my $PASSWD = $i++;
+my $GID = $i++;
+my $USERS = $i++;
# quite generic data
$group_names = "/etc/group";
@@ -222,9 +223,8 @@ sub change_group
sub get
{
my ($ifh, @groups, $group_last_modified);
- my (@line, $copy, @a, $counter);
+ my (@line, $copy, @a);
- $counter = 1;
$ifh = &Utils::File::open_read_from_names($group_names);
return unless ($ifh);
@@ -239,12 +239,10 @@ sub get
next if &Utils::Util::ignore_line ($_);
@line = split ':', $_, -1;
- unshift @line, $counter;
@a = split ',', pop @line;
push @line, [@a];
$copy = [@line];
push (@groups, $copy);
- $counter++;
}
&Utils::File::close_file ($ifh);
@@ -273,16 +271,16 @@ sub set
$old_config = &get ();
- foreach $i (@$config)
+ foreach $i (@$config)
{
- $groups{$$i[0]} |= 1;
- $config_hash{$$i[0]} = $i;
- }
-
+ $groups{$$i[$LOGIN]} |= 1;
+ $config_hash{$$i[$LOGIN]} = $i;
+ }
+
foreach $i (@$old_config)
{
- $groups{$$i[0]} |= 2;
- $old_config_hash{$$i[0]} = $i;
+ $groups{$$i[$LOGIN]} |= 2;
+ $old_config_hash{$$i[$LOGIN]} = $i;
}
# Delete all groups that only appeared in the old configuration
diff --git a/Users/Users.pm b/Users/Users.pm
index b47f8fb..03d77a2 100644
--- a/Users/Users.pm
+++ b/Users/Users.pm
@@ -73,14 +73,14 @@ $cmd_chfn = &Utils::File::locate_tool ("chfn");
$cmd_pw = &Utils::File::locate_tool ("pw");
# enum like for verbose group array positions
-my $ID = 0;
-my $LOGIN = 1;
-my $PASSWD = 2;
-my $UID = 3;
-my $GID = 4;
-my $COMMENT = 5;
-my $HOME = 6;
-my $SHELL = 7;
+my $i = 0;
+my $LOGIN = $i++;
+my $PASSWD = $i++;
+my $UID = $i++;
+my $GID = $i++;
+my $COMMENT = $i++;
+my $HOME = $i++;
+my $SHELL = $i++;
%login_defs_prop_map = ();
%profiles_prop_map = ();
@@ -376,10 +376,9 @@ sub get_logindefs
sub get
{
my ($ifh, @users, %users_hash);
- my (@line, @users, $counter);
+ my (@line, @users);
# Find the passwd file.
- $counter = 1;
$ifh = &Utils::File::open_read_from_names(@passwd_names);
return unless ($ifh);
@@ -390,9 +389,6 @@ sub get
next if &Utils::Util::ignore_line ($_);
@line = split ':', $_, -1;
- unshift @line, $counter;
- $counter++;
-
$login = $line[$LOGIN];
@comment = split ',', $line[$COMMENT], 5;