| 1 | #!/usr/bin/perl -Tw | ||||||||||||||||||||||||||||||||||||||||||
| 2 | #Copyright 1998-2001, Randall Maas. All rights reserved. This program is free | ||||||||||||||||||||||||||||||||||||||||||
| 3 | #software; you can redistribute it and/or modify it under the same terms as | ||||||||||||||||||||||||||||||||||||||||||
| 4 | #PERL itself. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | package CfgTie::TieUser; | ||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | require CfgTie::filever; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | require CfgTie::Cfgfile; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | require Secure::File; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | CfgTie::TieUser -- an associative array of user names and ids to information | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | makes the user database available as a regular hash. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | tie %user,'CfgTie::TieUser' | ||||||||||||||||||||||||||||||||||||||||||
| 21 | print "randym's full name: ", $user{'randym'}->{gcos}, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | This is a straightforward hash tie that allows us to access the user database | ||||||||||||||||||||||||||||||||||||||||||
| 26 | sanely. | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | It cross ties with the groups packages and the mail packages | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | =head2 Ties | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | There are two ties available for programmers: | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | =over 1 | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | =item C<tie %user,'CfgTie::TieUser'> | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | C<$user{$name}> will return a hash reference of the named user information. | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | =item C<tie %user_id,'CfgTie::TieUser_id'> | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | C<$user_id{$id}> will return a hash reference for the specified user. | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | =head2 Structure of hash | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | Any given user entry has the following information associated with it (the | ||||||||||||||||||||||||||||||||||||||||||
| 49 | keys are case-insensitive): | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | =over 1 | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | =item C<Name> | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | Login name | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | =item C<GroupId> | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | The principle group the user belongs to. | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | =item C<Id> | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | The user id number that they have been assigned. It is possible for many | ||||||||||||||||||||||||||||||||||||||||||
| 64 | different user names to be given the same id. However, changing the id for | ||||||||||||||||||||||||||||||||||||||||||
| 65 | the user (i.e., setting it to a new one) has one of two effects. If | ||||||||||||||||||||||||||||||||||||||||||
| 66 | C<user'Chg_FS> is set 1, then all the files in the system owned by that id | ||||||||||||||||||||||||||||||||||||||||||
| 67 | will changed to the new id in addition to changing the id in the system table. | ||||||||||||||||||||||||||||||||||||||||||
| 68 | Otherwise, only the system table will be modified. | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | =item C<Comment> | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | =item C<Home> | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | The user's home folder | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | =item C<LOGIN_Last> | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | This is the information from the last time the user logged in. It is an | ||||||||||||||||||||||||||||||||||||||||||
| 79 | array reference to data like: | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | [$time, $line, $from_host] | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =item C<Shell> | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | The user's shell | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | =item C<AuthMethod> | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | The authentication method if other than the default. (Note: This can be set, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | but currently can't get fetched.) | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | =item C<ExpireDate> | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | The date the account expires on. | ||||||||||||||||||||||||||||||||||||||||||
| 95 | (Note: this can be set, but currently can't be fetched.) | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | =item C<Inactive> | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | The number of days after a password expires. | ||||||||||||||||||||||||||||||||||||||||||
| 100 | (Note: this can be set, but currently can't be fetched.) | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | =item C<Priority> | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | The scheduling priority for that user. | ||||||||||||||||||||||||||||||||||||||||||
| 105 | (Note: this requires that C<BSD::Resource> be installed.) | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | =item C<Quota> | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | =item C<RUsage> | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | The process resource consumption by the user. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | Note: This requires that C<BSD::Resource> be installed. | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | Returns a list reference of the form: | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | [$usertime, $systemtime, $maxrss, $ixrss, $idrss, $isrss, $minflt, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | $majflt, $nswap, $inblock, $oublock, $msgsnd, $msgrcv, $nsignals, | ||||||||||||||||||||||||||||||||||||||||||
| 118 | $nvcsw, $nivcsw] | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | Plus two (probably) obsolete fields: | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | =over 1 | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | =item C<Password> | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | This is the encrypted password, but will probably be obsolete. | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | =item C<GCOS> | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | I<General Electric Comprehensive Operating System> or | ||||||||||||||||||||||||||||||||||||||||||
| 134 | I<General Comprehensive Operating System> | ||||||||||||||||||||||||||||||||||||||||||
| 135 | field | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | This is now the user's full name under many Unix's, incl. Linux. | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | Each of these entries can be modified (even deleted), and they will be | ||||||||||||||||||||||||||||||||||||||||||
| 142 | reflected in the overall system. Additionally, the programmer can set any | ||||||||||||||||||||||||||||||||||||||||||
| 143 | other associated key, but this information will only be available to the | ||||||||||||||||||||||||||||||||||||||||||
| 144 | running Perl script. | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | =head2 Configuration Variables | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | =head2 Additional Routines | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | =over 1 | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | =item C<&CfgTie::TieUser'stat()> | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | =item C<&CfgTie::TieUser_id'stat()> | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | Will return C<stat>-like statistics information on the user database. | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | =head2 Adding or overiding methods for user records | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | Lets say you wanted to change the default HTML handling to a different method. | ||||||||||||||||||||||||||||||||||||||||||
| 163 | To do this you need only include code like the following: | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | package CfgTie::TieUser_rec; | ||||||||||||||||||||||||||||||||||||||||||
| 166 | sub HTML($) | ||||||||||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | my $self=shift; | ||||||||||||||||||||||||||||||||||||||||||
| 169 | "<h1>".$Self->{name}."</h1>\n". | ||||||||||||||||||||||||||||||||||||||||||
| 170 | "<table border=0><tr><th align=right>\n". | ||||||||||||||||||||||||||||||||||||||||||
| 171 | join("</td></tr>\n<tr><th align=right>", | ||||||||||||||||||||||||||||||||||||||||||
| 172 | map {$_."</th><td>".$self->{$_}} (sort keys %{$self}) | ||||||||||||||||||||||||||||||||||||||||||
| 173 | </td></tr><lt></table>C<\n>"; | ||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | If, instead, you wanted to add your own keys to the user records, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | C<CfgTie::TieUser::add_scalar(>I<$Name>,I<$Package>C<)> | ||||||||||||||||||||||||||||||||||||||||||
| 178 | Lets you add scalar keys to user records. The I<Name> specifies the key name | ||||||||||||||||||||||||||||||||||||||||||
| 179 | to be used; it will be made case-insensitve. The I<Package> specifies the name | ||||||||||||||||||||||||||||||||||||||||||
| 180 | of the package to be used when tie'ing the key to a value. (The C<TIESCALAR> | ||||||||||||||||||||||||||||||||||||||||||
| 181 | is passed the user id as a parameter). | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | C<CfgTie::TieUser::add_hash(>I<$Name>,I<$Package>C<)> | ||||||||||||||||||||||||||||||||||||||||||
| 184 | Lets you add hash keys to user records. The I<Name> specifies the key name | ||||||||||||||||||||||||||||||||||||||||||
| 185 | to be used; it will be made case insensitve. The I<Package> specifies the name | ||||||||||||||||||||||||||||||||||||||||||
| 186 | of the package to be used when tie'ing the key to a value. (The C<TIEHASH> | ||||||||||||||||||||||||||||||||||||||||||
| 187 | is passed the user id as a parameter). | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | =head2 Miscellaneous | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | C<$CfgTie::TieUser_rec'usermod> contains the path to the program F<usermod>. | ||||||||||||||||||||||||||||||||||||||||||
| 192 | This can be modified as required. | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | C<$CfgTie::TieUser_rec'useradd> contains the path to the program F<useradd>. | ||||||||||||||||||||||||||||||||||||||||||
| 195 | This can be modified as required. | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | C<$CfgTie::TieUser_rec'userdel> contains the path to the program F<userdel>. | ||||||||||||||||||||||||||||||||||||||||||
| 198 | This can be modified as required. | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | Not all keys are supported on all systems. | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | This may transparently use a shadow tie in the future. | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | =head2 When the changes are reflected to /etc/passwd | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | =head1 Files | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | F</etc/passwd> | ||||||||||||||||||||||||||||||||||||||||||
| 209 | F</etc/group> | ||||||||||||||||||||||||||||||||||||||||||
| 210 | F</etc/shadow> | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | =head1 See Also | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | L<CfgTie::Cfgfile>, L<CfgTie::TieAliases>, L<CfgTie::TieGeneric>, | ||||||||||||||||||||||||||||||||||||||||||
| 215 | L<CfgTie::TieGroup>,L<CfgTie::TieHost>, L<CfgTie::TieMTab>, | ||||||||||||||||||||||||||||||||||||||||||
| 216 | L<CfgTie::TieNamed>,L<CfgTie::TieNet>, L<CfgTie::TiePh>, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | L<CfgTie::TieProto>,L<CfgTie::TieRCService>,L<CfgTie::TieRsrc>, | ||||||||||||||||||||||||||||||||||||||||||
| 218 | L<CfgTie::TieServ>, L<CfgTie::TieShadow> | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | L<group(5)>, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | L<passwd(5)>, | ||||||||||||||||||||||||||||||||||||||||||
| 222 | L<shadow(5)>, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | L<usermod(8)>, | ||||||||||||||||||||||||||||||||||||||||||
| 224 | L<useradd(8)>, | ||||||||||||||||||||||||||||||||||||||||||
| 225 | L<userdel(8)> | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | =head1 Caveats | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | The current version does cache some user information. | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | =head1 Author | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | Randall Maas (L<randym@acm.org>) | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | my $Chg_FS = 1; #By default we want to update the file system when the user | |||||||||||||||||||||||||||||||||||||||||
| 238 | # Id changes | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | sub stat($) | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stat: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | # the information for the /etc/passwd file | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | stat '/etc/passwd'; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | sub TIEHASH | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | my $node = {}; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | return bless $node, $self; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | sub FIRSTKEY | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | #Rewind outselves to the beginning. | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | setpwent; | |||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | &NEXTKEY($self); | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | sub NEXTKEY | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | #Get the next user id in the database. | ||||||||||||||||||||||||||||||||||||||||||
| 268 | # Get the information from the system and store it for later | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my @x = getpwent; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if (!scalar @x) {return;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | &CfgTie::TieUser_rec'TIEHASH(0,@x); | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return $x[0]; #Corresponds to the name | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | sub EXISTS | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my ($self,$name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $lname =lc($name); | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if (exists $CfgTie::TieUser_rec'by_name{$lname}) {return 1;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | # Get the information from the system and store it for later | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my @x = getpwnam $name; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if (! scalar @x) {return 0;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | tie %{$CfgTie::TieUser_rec'by_name{lc($x[0])}}, 'CfgTie::TieUser_rec',@x; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | sub FETCH | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if (!defined $name) {return;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $lname = lc($name); | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | #check out our cache first | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if (EXISTS($self,$lname)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | {return $CfgTie::TieUser_rec'by_name{$lname};} | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | #Bug creating users is not supported yet. | ||||||||||||||||||||||||||||||||||||||||||
| 304 | sub STORE | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my ($self,$key,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 307 | # useradd or usermod, depending | ||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | #Bug need to consider how vigorously we delete things -r ? /var/mail/me, etc | ||||||||||||||||||||||||||||||||||||||||||
| 311 | sub DELETE | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DELETE: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | #Basically delete the user now. | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | CfgTie::filver::system("$CfgTie::TieUser_rec'userdel $name"); | |||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | #Remove it from our cache | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | if (exists $CfgTie::TieUser_rec'by_name{$name}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | {delete $CfgTie::TieUser_rec'by_name{$name};} | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | sub HTML($$) | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HTML: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my ($self,$CodeRef)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my %A; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | for (my $I=FIRSTKEY($self); $I; $I=NEXTKEY($self,$I)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | { | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $U=FETCH($self,$I); | |||||||||||||||||||||||||||||||||||||||||
| 331 | #See if the caller wants us to pass | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | if (defined $CodeRef && !&$CodeRef($U)) {next;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $CodeRef and not &$CodeRef($U)
MC/DC0%0/2
defined $CodeRef and not &$CodeRef($U)
defined $CodeRef
not &$CodeRef($U)
Truth table0%0/3
A and not(B)
A= defined $CodeRefB= not &$CodeRef($U)
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | $A{$I} = CfgTie::Cfgfile::trx( | ||||||||||||||||||||||||||||||||||||||||||
| 334 | "<a href=\"user/$I\">$I</a>", | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $U->{'gcos'}, | |||||||||||||||||||||||||||||||||||||||||
| 336 | "<a href=\"mailto:$I\">$I</a>" | ||||||||||||||||||||||||||||||||||||||||||
| 337 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $Us; | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | foreach my $I (sort keys %A) {$Us.=$A{$I};} | |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | CfgTie::Cfgfile::table('Users', | |||||||||||||||||||||||||||||||||||||||||
| 342 | "<th class=\"cfgattr\">login</th><th class=\"cfgattr\">Full Name</th>". | ||||||||||||||||||||||||||||||||||||||||||
| 343 | "<th class=\"cfgattr\">mailto:</th></tr>\n".$Us, 3); | ||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | sub add_scalar($$) | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_scalar: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my ($name,$package) =@_; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $name=lc($name); | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $CfgTie::TieUser_rec::SDelegates->{$name}=$package; | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | sub add_hash($$) | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my ($name,$package) =@_; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $name=lc($name); | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $CfgTie::TieUser_rec::HDelegates->{$name}=$package; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | package CfgTie::TieUser_id; | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | sub status | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | # the information for the /etc/passwd file | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | stat '/etc/passwd'; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | sub TIEHASH | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $node = {}; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | return bless $node, $self; | |||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | sub FIRSTKEY | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | #Rewind outselves to the beginning. | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | setpwent; | |||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | &NEXTKEY($self); | |||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | sub NEXTKEY | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | #Get the next user id in the database. | ||||||||||||||||||||||||||||||||||||||||||
| 391 | # Get the information from the system and store it for later | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my @x = getpwent; | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | if (! scalar @x) {return;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | &CfgTie::TieUser_rec'TIEHASH(0,@x); | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | return $x[2]; #Corresponds to the id | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | sub EXISTS | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my ($self,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if (exists $CfgTie::TieUser_rec'by_id{$id}) {return 1;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | # Get the information from the system and store it for later | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my @x = getpwuid $id; | |||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if (! scalar @x) {return 0;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | tie %{$CfgTie::TieUser_rec'by_name{lc($x[0])}}, 'CfgTie::TieUser_rec',@x; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $CfgTie::TieUser_rec'by_id{$id} = $CfgTie::TieUser_rec'by_name{$x[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | sub FETCH | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my ($self,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | #check out our cache first | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | if (EXISTS($self,$id)) {return $CfgTie::TieUser_rec'by_id{$id};} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | #Bug creating users is not supported yet. | ||||||||||||||||||||||||||||||||||||||||||
| 422 | sub STORE | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my ($self,$key,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 425 | # useradd or usermod, depending | ||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | #Bug need to consider how vigorously we delete things -r ? /var/mail/me, etc | ||||||||||||||||||||||||||||||||||||||||||
| 429 | sub DELETE | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DELETE: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my ($self,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | if (!exists $CfgTie::TieUser_rec'by_id{$id}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | { | ||||||||||||||||||||||||||||||||||||||||||
| 435 | #Try to look up the user id | ||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | FETCH($self,$id); | |||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | if (exists $CfgTie::TieUser_rec'by_id{$id}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | { | ||||||||||||||||||||||||||||||||||||||||||
| 441 | #Basically delete the user now. | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | CfgTie::filever::system | |||||||||||||||||||||||||||||||||||||||||
| 443 | ("$CfgTie::TieUser_rec'userdel $CfgTie::TieUser_rec'by_id{$id}->{Name}"); | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | #Remove it from out cache | ||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | delete $CfgTie::TieUser_rec'by_id{$id}; | |||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | package CfgTie::TieUser_rec; | ||||||||||||||||||||||||||||||||||||||||||
| 453 | # A package used by both user_id and user to retain record information about | ||||||||||||||||||||||||||||||||||||||||||
| 454 | # a person. This is the only way to access usermod. | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | #Two hashes are used for look up | ||||||||||||||||||||||||||||||||||||||||||
| 457 | # $by_name{$name} | ||||||||||||||||||||||||||||||||||||||||||
| 458 | # $by_id{$id} | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | #Delegate keys | ||||||||||||||||||||||||||||||||||||||||||
| 461 | # This are looked up by a delegate system that we basically add on | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 1 | my $HDelegates={}; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 1 | my $SDelegates={}; | |||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | #Extended keys | ||||||||||||||||||||||||||||||||||||||||||
| 466 | 1 | my $EKeys = {'last'=>[],login_last=>[]}; | |||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | sub new {&TIEHASH(@_);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | sub TIEHASH | ||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | # Ties a single user to a register... | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my ($self,$Name,@Rest) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my $Node; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $lname = lc($Name); | |||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | if (scalar @Rest) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | { | ||||||||||||||||||||||||||||||||||||||||||
| 479 | ($Node->{password},$Node->{id}, $Node->{groupid}, | ||||||||||||||||||||||||||||||||||||||||||
| 480 | $Node->{quota}, $Node->{comment}, $Node->{gcos}, $Node->{home}, | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $Node->{shell}) = @Rest; | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | if (defined $Name) {$Node->{name}=$Name;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | #Add in the delegates | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | foreach my $I (keys %{$HDelegates}) | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | {tie %{$Node->{$I}}, $HDelegates->{$I}, $Node->{id};} | |||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | foreach my $I (keys %{$SDelegates}) | |||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | {tie $Node->{$I}, $SDelegates->{$I}, $Node->{id};} | |||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | return bless $Node, $self; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | sub FIRSTKEY | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $a = keys %{$self}; | |||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | NEXTKEY($self,undef); | |||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | sub NEXTKEY ($$) | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my ($self,$prev) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my $a = scalar each %{$self}; | |||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | if ($a) {return $a;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | ###The following is busted | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | #Should also return something from the extended keys if not already set. | ||||||||||||||||||||||||||||||||||||||||||
| 511 | #if (!exists $EKeys->{$prev}) {my $a = keys %{$EKeys};} | ||||||||||||||||||||||||||||||||||||||||||
| 512 | #while ($a = scalar each %{$EKeys}) | ||||||||||||||||||||||||||||||||||||||||||
| 513 | # { | ||||||||||||||||||||||||||||||||||||||||||
| 514 | # if (exists $self->{$a}) {next;} | ||||||||||||||||||||||||||||||||||||||||||
| 515 | # return $a; | ||||||||||||||||||||||||||||||||||||||||||
| 516 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | return $a; | |||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | #Modified from PERL Cookbook: | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 1 | my $lastlog_fmt="L a16 A16"; #on sunos "L A8 A16" | |||||||||||||||||||||||||||||||||||||||||
| 522 | sub lastlog_FETCH($) | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lastlog_FETCH: not called CC=6 SCAR=31.8
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 1 | ▶ | use User::pwent; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 1 | ▶ | use IO::Seekable qw(SEEK_SET); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $LASTLOG= new Secure::File "</var/log/lastlog"; | |||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | return unless defined $LASTLOG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my $User = shift; | |||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | my $U = ($User =~ /^\d+$/) ? getpwuid($User) : getpwnam($User); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | if (!$U) {goto ret_from_here;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | my $R; | |||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $sizeof = length(pack($lastlog_fmt,())); | |||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if ($LASTLOG->seek($U->uid + $sizeof,SEEK_SET) && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$LASTLOG->seek($U->uid + $sizeof, 0) and $LASTLOG->read($buffer, $sizeof) == $sizeof
MC/DC0%0/2
$LASTLOG->seek($U->uid + $sizeof, 0) and $LASTLOG->read($buffer, $sizeof) == $sizeof
$LASTLOG->seek($U->uid + $sizeof, 0)
$LASTLOG->read($buffer, $sizeof) == $sizeof
Truth table0%0/3
A and B
A= $LASTLOG->seek($U->uid + $sizeof, 0)B= $LASTLOG->read($buffer, $sizeof) == $sizeof
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | $LASTLOG->read($buffer, $sizeof) == $sizeof) | ||||||||||||||||||||||||||||||||||||||||||
| 538 | { | ||||||||||||||||||||||||||||||||||||||||||
| 539 | #time line host | ||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | $R = [unpack($lastlog_fmt, $buffer)]; | |||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | ret_from_here: | ||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | $LASTLOG->close; | |||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | $R; | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | sub scan_lasts | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan_lasts: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | #Get the last time the read their email | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $L = new Secure::File "</var/log/maillog"; | |||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | while (<$L>) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | { | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | if(/([\d\w\s:]+)\s\w+\s\w+\[\d+\]:\sLogout\suser\s(\w+).*/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | {$Last{lc($2)} = $1;} | |||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $L->close; | |||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | sub EXISTS | ||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my ($self,$key) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $lkey=lc($key); | |||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | #first, check to see if it is a forbidden key | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | if ($lkey eq 'delegate') {return 0;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | #Next, check the delegates | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | if (exists $self->{delegate}->{$lkey}) {return 1;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | #otherwise check the rest | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | if ($lkey eq 'login_last' && !exists $self->{'login_last'}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$lkey eq "login_last" and not exists $self->{"login_last"}
MC/DC0%0/2
$lkey eq "login_last" and not exists $self->{"login_last"}
$lkey eq "login_last"
not exists $self->{"login_last"}
Truth table0%0/3
A and not(B)
A= $lkey eq "login_last"B= not exists $self->{"login_last"}
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | { | ||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | my $R = lastlog_FETCH($self->{name}); | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if (undef $R) {return 0;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $self->{'login_last'} = $R; | |||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | ▶ | elsif ($lkey eq 'last' && !exists $self->{'last'}) | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$lkey eq "last" and not exists $self->{"last"}
MC/DC0%0/2
$lkey eq "last" and not exists $self->{"last"}
$lkey eq "last"
not exists $self->{"last"}
Truth table0%0/3
A and not(B)
A= $lkey eq "last"B= not exists $self->{"last"}
| |||||||||||||||||||||||||||||||||||||||||||
| 580 | { | ||||||||||||||||||||||||||||||||||||||||||
| 581 | #Try to recover it from our shadow, but avoid scanning the last | ||||||||||||||||||||||||||||||||||||||||||
| 582 | #file if we can -- it takes a *long* time | ||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | if (!exists $Last{lc($self->{name})} && !defined $scanned_last) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $Last{lc $self->{"name"}} or defined $scanned_last
MC/DC0%0/2
exists $Last{lc $self->{"name"}} or defined $scanned_last
exists $Last{lc $self->{"name"}}
defined $scanned_last
Truth table0%0/3
A or B
A= exists $Last{lc $self->{"name"}}B= defined $scanned_last
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | { | ||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | &scan_lasts(); | |||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $scanned_last=1; | |||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | if (exists $Last{lc($self->{name})}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | {$self->{'last'} = $Last{lc($self->{name})};} | |||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | return exists $self->{$lkey}; | |||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | sub FETCH | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my ($self,$key) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $lkey = lc($key); | |||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | #Check the delegated stuff | ||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | if (exists $self->{delegate}->{$lkey}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | {return $self->{delegate}->{$lkey}->FETCH($key);} | |||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | if (!exists $self->{$lkey}) {EXISTS($self,$lkey);} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | if (exists $self->{$lkey}) {return $self->{$lkey};} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | # Maps the changes to a particular setting to a flag on the command line | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 1 | my $usermod_opt = | |||||||||||||||||||||||||||||||||||||||||
| 610 | { | ||||||||||||||||||||||||||||||||||||||||||
| 611 | comment => '-c', | ||||||||||||||||||||||||||||||||||||||||||
| 612 | home => '-d', | ||||||||||||||||||||||||||||||||||||||||||
| 613 | expire => '-e', | ||||||||||||||||||||||||||||||||||||||||||
| 614 | inactive=> '-f', | ||||||||||||||||||||||||||||||||||||||||||
| 615 | name => '-l', | ||||||||||||||||||||||||||||||||||||||||||
| 616 | shell => '-s', | ||||||||||||||||||||||||||||||||||||||||||
| 617 | group1 => '-g', | ||||||||||||||||||||||||||||||||||||||||||
| 618 | groups => '-G', | ||||||||||||||||||||||||||||||||||||||||||
| 619 | id => '-u', | ||||||||||||||||||||||||||||||||||||||||||
| 620 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | 1 | my $usermod_opt2 = | |||||||||||||||||||||||||||||||||||||||||
| 623 | { | ||||||||||||||||||||||||||||||||||||||||||
| 624 | id => '-o', | ||||||||||||||||||||||||||||||||||||||||||
| 625 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | 1 | my $usermod = '/usr/sbin/usermod'; #Hard path to usermod | |||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | my $userdel = '/usr/sbin/userdel'; #Hard path to userdel | |||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | sub STORE | ||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | # Changes a setting for the specified user... we basically call usermod | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my ($self,$key,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my $lkey = lc($key); | |||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | #Check the delegated stuff | ||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if (exists $self->{delegate}->{$lkey}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | {return $self->{delegate}->{$lkey}->STORE($key,$val);} | |||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | if ($lkey eq 'groups') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | { | ||||||||||||||||||||||||||||||||||||||||||
| 642 | #Handle the groups thing... | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | #$val is a list reference.... | ||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my ($i,@g) = @{$val}; | |||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | CfgTie::filever::system("$usermod $self->{name} -g $i -G ". join(',', @g)); | |||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||
| 649 | elsif (exists $usermod_opt->{$lkey}) | ||||||||||||||||||||||||||||||||||||||||||
| 650 | { | ||||||||||||||||||||||||||||||||||||||||||
| 651 | #This is something for user mod! | ||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | my ($FSUp, @FSet)=(0); | |||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if (defined $user'Chg_FS && $user'Chg_FS == 1 && $lkey eq 'id') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $user::Chg_FS and $user::Chg_FS == 1 and $lkey eq "id"
defined $user::Chg_FS and $user::Chg_FS == 1
MC/DC0%0/3
defined $user::Chg_FS and $user::Chg_FS == 1 and $lkey eq "id"
defined $user::Chg_FS
$user::Chg_FS == 1
$lkey eq "id"
Truth table0%0/4
A and B and C
A= defined $user::Chg_FSB= $user::Chg_FS == 1C= $lkey eq "id"
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | { | ||||||||||||||||||||||||||||||||||||||||||
| 656 | #We are supposed to change all of the files in the system to | ||||||||||||||||||||||||||||||||||||||||||
| 657 | #have the new new one. | ||||||||||||||||||||||||||||||||||||||||||
| 658 | #We have a race condition: someone else may change soemthing in | ||||||||||||||||||||||||||||||||||||||||||
| 659 | #the file system, so we may not get everything, but we try to | ||||||||||||||||||||||||||||||||||||||||||
| 660 | #be reasonable | ||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | # Now we need to identify all of the files.. this may take a | ||||||||||||||||||||||||||||||||||||||||||
| 663 | # long time | ||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | @FSet= &CfgTie::filever'find_by_user ('/', $self->{id}); | |||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if (@FSet && scalar @FSet) {$FSUp = 1;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
@FSet and scalar @FSet
MC/DC0%0/1
@FSet and scalar @FSet
@FSet
Truth table0%0/2
A
A= @FSet
| |||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my $X = $usermod_opt2->{$lkey}; | |||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | if (!defined $X) {$X='';} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | #Change the system tables | ||||||||||||||||||||||||||||||||||||||||||
| 673 | CfgTie::filever::system("$usermod ".$usermod_opt->{$lkey}." $val $X ". | ||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | $self->{name}."\n"); | |||||||||||||||||||||||||||||||||||||||||
| 675 | #If bad things should throw exception | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | if ($FSUp) {chown $val,-1, @FSet;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | $self->{$lkey} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | else | ||||||||||||||||||||||||||||||||||||||||||
| 682 | { | ||||||||||||||||||||||||||||||||||||||||||
| 683 | #Extra setting that will be lost... 8( | ||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | $self->{$lkey}=$val; | |||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | sub DELETE | ||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DELETE: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 690 | #Deletes a user setting | ||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | my $lkey=lc($key); | |||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | if ($lkey eq 'authmethod') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | { | ||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | CfgTie::filever::system("$usermod -A DEFAULT ".$self->{name}); | |||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||
| 698 | elsif (exists $usermod_opt->{$lkey}) | ||||||||||||||||||||||||||||||||||||||||||
| 699 | { | ||||||||||||||||||||||||||||||||||||||||||
| 700 | #This is something for user mod! | ||||||||||||||||||||||||||||||||||||||||||
| 701 | CfgTie::filever::system("$usermod ".$usermod_opt->{$lkey}." ". | ||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | $self->{name}); | |||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||
| 704 | else | ||||||||||||||||||||||||||||||||||||||||||
| 705 | { | ||||||||||||||||||||||||||||||||||||||||||
| 706 | #Just remove our local copy | ||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | delete $self->{$lkey}; | |||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | sub trx {CfgTie::Cfgfile::trx(@_);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trx: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | sub HTML($) | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HTML: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | # A routine to HTMLize the user | ||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my %Keys2 = map {$_,1} (keys %{$self}); | |||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | $Keys2{'last'}=1; | |||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | delete $Keys2{gcos}; | |||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | delete $Keys2{name}; | |||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | delete $Keys2{id}; | |||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | delete $Keys2{groupid}; | |||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | delete $Keys2{password}; | |||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | my ($G) = getgrgid($self->{groupid}); | |||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | my $A=''; | |||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | foreach my $I (sort keys %Keys2) {$A.=trx($I,$self->{$I});} | |||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | CfgTie::Cfgfile::table($self->{gcos}, | ||||||||||||||||||||||||||||||||||||||||||
| 731 | trx("Full Name:", $self->{gcos}). | ||||||||||||||||||||||||||||||||||||||||||
| 732 | trx("Login (UID):",$self->{name}." (".$self->{id}.")"). | ||||||||||||||||||||||||||||||||||||||||||
| 733 | trx("Group (GID):","<a href=\"group/$G\">".$G."</a> (". | ||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | $self->{groupid}.")").$A); | |||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | ## --- Support for optional user prioritization -------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 738 | package CfgTie::TieUser_priority; | ||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | if (eval("use BSD::Resource;")) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 740 | { | ||||||||||||||||||||||||||||||||||||||||||
| 741 | #Add the BSD stuff in | ||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $CfgTie::TieUser_rec::SDelegate{'priority'}='CfgTie::TieUser_priority'; | |||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | $CfgTie::TieUser_rec::SDelegate{'rusage'}='CfgTie::TieUser_rusage'; | |||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | sub TIESCALAR | ||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | {return bless {id=>$_[1]}, $_[0];} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIESCALAR: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | sub FETCH | ||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | #Get the priority setting from the system | ||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | getpriority(PRIO_USER,$_[0]->{id}); | |||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | sub STORE | ||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | my ($self,$val)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | #Pass the priority setting onto the system | ||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | setpriority(PRIO_USER,$self->{id},$val); | |||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | ## --- Support for optional user resources ------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 764 | package CfgTie::TieUser_rusage; | ||||||||||||||||||||||||||||||||||||||||||
| 765 | sub TIEHASH | ||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | {return bless {id=>$_[1]}, $_[0];} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | #Get the consumption data from the system | ||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | sub FETCH { [getrusage($_[0]->{id})]; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||
| 771 | ## --- Support for optional Quotas -------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 772 | package CfgTie::TieUser_quota; | ||||||||||||||||||||||||||||||||||||||||||
| 773 | #This part attempts to tie in the quota package. It is not guaranteed to | ||||||||||||||||||||||||||||||||||||||||||
| 774 | #succeed. Quota from CPAN is recommended because of its completenes of API | ||||||||||||||||||||||||||||||||||||||||||
| 775 | #and broad range of platforms supported. | ||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | if (eval("use Quota;")) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 778 | { | ||||||||||||||||||||||||||||||||||||||||||
| 779 | #Add the quota stuff in | ||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | $CfgTie::TieUser_rec::HDelegate{'usage'}='CfgTie::TieUser_quota_usage'; | |||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $CfgTie::TieUser_rec::HDelegate{'limits'}='CfgTie::TieUser_quota_limits'; | |||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | $CfgTie::TieUser_rec::HDelegate{'timeleft'}='CfgTie::TieUser_quota_timeleft'; | |||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | 1 | my $DB={usage=>{},timeleft=>{},limits=>{}}; | |||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | sub Query($$) | ||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Query: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 790 | #A wrapper around the Quota::query routine... converts into our internal | ||||||||||||||||||||||||||||||||||||||||||
| 791 | #usage form | ||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | my ($uid,$dev) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | #Get the information | ||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | my ($Block_Curr, $Block_Soft, $Block_Hard, $Block_TimeLeft, | |||||||||||||||||||||||||||||||||||||||||
| 797 | $INode_Curr, $INode_Soft, $INode_Hard, $INode_TimeLeft) = | ||||||||||||||||||||||||||||||||||||||||||
| 798 | Quota::query($dev,$uid); | ||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | #Now store it in a form we can use | ||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | $DB->{usage}-> {$uid}->{$dev} =[$Block_Curr, $INode_Curr]; | |||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | $DB->{timeleft}->{$uid}->{$dev} =[$Block_TimeLeft,$INode_TimeLeft]; | |||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | $DB->{limits}-> {$uid}->{$dev} =[$Block_Soft,$Block_Hard,$INode_Soft,$INode_Hard]; | |||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | sub Exists ($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Exists: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | my($self,$key,$path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | #Convert the path into q form that can be used in a query | ||||||||||||||||||||||||||||||||||||||||||
| 812 | #(The representation will vary with each system) | ||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | my $dev = Query::getqcarg($key); | |||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | if (!exists $DB->{$key}->{$self->{uid}}->{$dev}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | {Query($self->{uid},$dev);} | |||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | return exists $DB->{$key}->{$self->{uid}}->{$dev}; | |||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | sub Fetch ($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Fetch: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | my($self,$key,$path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | #Convert the path into q form that can be used in a query | ||||||||||||||||||||||||||||||||||||||||||
| 826 | #(The representation will vary with each system) | ||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | my $dev = Query::getqcarg($key); | |||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | if (!exists $DB->{$key}->{$self->{uid}}->{$dev}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | {Query($self->{uid},$dev);} | |||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | ▶ | if (exists $DB->{$key} && exists $DB->{$key}->{$self->{uid}}->{$dev}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $DB->{$key} and exists $DB->{$key}{$self->{"uid"}}{$dev}
MC/DC0%0/2
exists $DB->{$key} and exists $DB->{$key}{$self->{"uid"}}{$dev}
exists $DB->{$key}
exists $DB->{$key}{$self->{"uid"}}{$dev}
Truth table0%0/3
A and B
A= exists $DB->{$key}B= exists $DB->{$key}{$self->{"uid"}}{$dev}
| |||||||||||||||||||||||||||||||||||||||||||
| 834 | { | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | return $DB->{$key}->{$self->{uid}}->{$dev}; | |||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | package CfgTie::TieUser_quota_limits; | ||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | sub new(@_) {TIEHASH(@_);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | sub TIEHASH {return bless {uid=>$_[1]}, $_[0];} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | sub EXISTS ($$) {CfgTie::TieUser_quota::Exists($_[0],'limits',$_[1]);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | sub FETCH ($$) {CfgTie::TieUser_quota::Fetch($_[0],'limits',$_[1]);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | sub STORE ($$) | ||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my ($self,$key,$val)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | #Convert the path into q form that can be used in a query | ||||||||||||||||||||||||||||||||||||||||||
| 851 | #(The representation will vary with each system) | ||||||||||||||||||||||||||||||||||||||||||
| 852 | #The key is the path | ||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | my $dev = Query::getqcarg($key); | |||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | #clear out the keys | ||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | delete $limits{$self->{uid}}; | |||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | Quota::setqlim($dev, $self->{uid}, @{$val}); | |||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | package CfgTie::TieUser_quota_usage; | ||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | sub new(@_) {TIEHASH(@_);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | sub TIEHASH {return bless {uid=>$_[1]}, $_[0];} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | sub EXISTS ($$) {CfgTie::TieUser_quota::Exists($_[0],'usage',$_[1]);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | sub FETCH ($$) {CfgTie::TieUser_quota::Fetch ($_[0],'usage',$_[1]);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||
| 867 | package CfgTie::TieUser_quota_timeleft; | ||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | ▶ | sub new(@_) {TIEHASH(@_);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | sub TIEHASH {return bless {uid=>$_[1]}, $_[0];} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | sub EXISTS ($$) {CfgTie::TieUser_quota::Exists($_[0],'timeleft',$_[1]);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | sub FETCH ($$) {CfgTie::TieUser_quota::Fetch ($_[0],'timeleft',$_[1]);} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||
| 873 | package CfgTie::TieUser_file; | ||||||||||||||||||||||||||||||||||||||||||
| 874 | 1 | ▶ | use CfgTie::Cfgfile; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 875 | 1 | @ISA=qw(CfgTie::Cfgfile); | |||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | sub files | ||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
files: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | $self->{'Path'}; | |||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | sub status | ||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 884 | # the information for the file | ||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | stat $self->{'Path'}; | |||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||
| 888 | sub scan | ||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | #Check to see what the path is | ||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | if (!exists $self->{'Path'}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 894 | { | ||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | my $F= new Secure::File "<".$self->{'Path'}; | |||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | return unless defined $F; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | while (<$F>) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 902 | { | ||||||||||||||||||||||||||||||||||||||||||
| 903 | #Chop of the comments | ||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | s/\s*#.*$//; | |||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | my @x = split /:/; | |||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | if (@x && defined $x[0] && length $x[0]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@x and defined $x[0] and length $x[0]
@x and defined $x[0]
MC/DC0%0/3
@x and defined $x[0] and length $x[0]
@x
defined $x[0]
length $x[0]
Truth table0%0/4
A and B and C
A= @xB= defined $x[0]C= length $x[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 907 | { | ||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | $self->{Contents}->{$x[0]}={ | |||||||||||||||||||||||||||||||||||||||||
| 909 | 'name' =>$x[0], | ||||||||||||||||||||||||||||||||||||||||||
| 910 | 'passwd' =>$x[1], | ||||||||||||||||||||||||||||||||||||||||||
| 911 | 'id' =>$x[2], | ||||||||||||||||||||||||||||||||||||||||||
| 912 | 'members'=>[split(/(?:\s+|\,)/, $x[3])] | ||||||||||||||||||||||||||||||||||||||||||
| 913 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | $F->close; | |||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||
| 920 | sub format($$) | ||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | "$_[1]: ".join(',',@{$_[1]})."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||