Skip to content

Commit

Permalink
Remove ag_uid, inlining it in UsersCache.pm (bsc#1172139)
Browse files Browse the repository at this point in the history
Eliminating this Perl process saves 11 MiB of memory at installation time.
  • Loading branch information
Martin Vidner committed Aug 3, 2020
1 parent 0778d8d commit ebe9099
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 90 deletions.
2 changes: 0 additions & 2 deletions agent-nis/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions agent-uid/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions agents/.gitignore

This file was deleted.

4 changes: 1 addition & 3 deletions src/Makefile.am
Expand Up @@ -79,13 +79,11 @@ ylib_DATA = \
lib/users/widgets.rb

scrconf_DATA = \
scrconf/uid.scr \
scrconf/etc_default_useradd.scr \
scrconf/nis.scr

agent_SCRIPTS = \
servers_non_y2/ag_nis \
servers_non_y2/ag_uid
servers_non_y2/ag_nis

schemafilesdir = $(schemadir)/autoyast/rnc
schemafiles_DATA = \
Expand Down
21 changes: 17 additions & 4 deletions src/modules/UsersCache.pm
Expand Up @@ -29,6 +29,7 @@ use strict;

use YaST::YCP qw(:LOGGING);
use YaPI;
use User::pwent;

textdomain ("users");

Expand Down Expand Up @@ -232,9 +233,15 @@ sub CustomizedGroupsView {

##------------------------------------
sub UIDConflicts {
my $id = $_[0];

my $ret = SCR->Read (".uid.uid", $_[0]);
return !$ret;
my $pw = getpwuid($id);
if (defined $pw) {
my $name = $pw->name;
y2debug ("$id is UID of user $name");
return 1;
}
return 0;
}

##------------------------------------
Expand Down Expand Up @@ -273,9 +280,15 @@ sub UIDExists {
}

sub UsernameConflicts {
my $username = $_[0];

my $ret = SCR->Read (".uid.username", $_[0]);
return !$ret;
my $pw = getpwnam($username);
if (defined $pw) {
my $uid = $pw->uid;
y2debug ("$username is used with uid $uid");
return 1;
}
return 0;
}

##------------------------------------
Expand Down
14 changes: 0 additions & 14 deletions src/scrconf/uid.scr

This file was deleted.

63 changes: 0 additions & 63 deletions src/servers_non_y2/ag_uid

This file was deleted.

0 comments on commit ebe9099

Please sign in to comment.