Lines Matching +full:sub +full:- +full:group
42 # where the 0700 denotes "octal 7-0-0".
48 # &B_chmod ("u-s" , "/bin/mount")
50 # &B_chmod ("go-rwx", "/bin/mount")
55 # the permissions to the pre-Bastille state.
62 sub B_chmod($$) {
74 if ($new_perm =~ /([ugo]+)([+-]{1})([rwxst]+)/) {
105 # the current permissions, by OR-ing (for +) or XOR-ing (for -).
111 # the noun of "other","group","user", or "suid/sgid/sticky".
121 # a sum of powers of 8, corresponding to user/group/other,
172 elsif ($add_remove eq '-') {
187 if ( -e $file ) {
191 # if the distribution is HP-UX then the modifications should
193 if(&GetDistro =~ "^HP-UX"){
196 # making changes revert-able
222 # where the 0700 denotes "octal 7-0-0".
232 sub B_chmod_if_exists($$) {
241 if ( -e $file_expr ) {
254 # the file/directory owner to the pre-Bastille state.
264 sub B_chown($$) {
284 if ( -e $file ) {
289 # if the distribution is HP-UX then the modifications should
291 if(&GetDistro =~ "^HP-UX"){
294 # making ownership change revert-able
315 sub B_chown_link($$){
328 &B_log("ACTION","chown -h $newown,\"$original_file\";\n");
329 if ( -e $file ) {
331 `$chown -h $newown $file`;
334 # if the distribution is HP-UX then the modifications should
336 if(&GetDistro =~ "^HP-UX"){
339 # making ownership change revert-able
340 &B_revert_log("$chown -h $oldown $file\n");
356 # &B_chgrp ($gid, $file) sets the group owner of $file to $gid, like this:
362 # the file/directory group to the pre-Bastille state.
372 sub B_chgrp($$) {
390 &B_log("ACTION", "Change group ownership on $original_file from $oldgown to $newgown\n");
392 if ( -e $file ) {
394 # changing the group for the file/directory
397 # if the distribution is HP-UX then the modifications should
399 if(&GetDistro =~ "^HP-UX"){
423 sub B_chgrp_link($$) {
434 &B_log("ACTION","change group ownership on $original_file from $oldgown to $newgown\n");
435 &B_log("ACTION","chgrp -h $newgown \"$original_file\";\n");
436 if ( -e $file ) {
438 # do not follow link with option -h
439 `$chgrp -h $newgown $file`;
442 # if the distribution is HP-UX then the modifications should
444 if(&GetDistro =~ "^HP-UX"){
447 # making ownership change revert-able
448 &B_revert_log("$chgrp" . " -h $oldgown $file\n");
452 … &B_log("ERROR","Couldn't change group ownership to $newgown on file $original_file\n");
465 # /etc/passwd, /etc/shadow and /etc/group lines.
472 sub B_userdel($) {
476 if (&GetDistro =~ /^HP-UX/) {
479 # Not yet suported on HP-UX, where we'd need to support
509 # B:remove_user_from_group($user,$group)
516 # Parse /etc/group, looking for our user.
517 if (open GROUP,&getGlobal('FILE','group')) {
518 my @lines = <GROUP>;
519 close GROUP;
523 # Parse the line -- first field is group, last is users in group.
525 my $group = $1;
532 push @groups,$group;
541 foreach my $group (@groups) {
542 &B_remove_user_from_group($user_to_remove,$group);
551 # We should delete the user's group as well, if it's a single-user group.
553 if (open ETCGROUP,&getGlobal('FILE','group')) {
566 # B_groupdel($group) removes $group from /etc/group.
569 sub B_groupdel($) {
571 my $group = $_[0];
573 # First read /etc/group to make sure the group is in there.
574 if (open GROUP,&getGlobal('FILE','group')) {
575 my @lines=<GROUP>;
576 close GROUP;
578 # Delete the line in /etc/group if present
579 if (grep /^$group:/,@lines > 0) {
580 # The group is named in /etc/group
581 &B_delete_line(&getGlobal('FILE','group'),"^$group:/");
589 # B:remove_user_from_group($user,$group) removes $user from $group,
590 # by modifying $group's /etc/group line, pulling the user out. This
593 # ":\s*$user\s*," --> ":"
594 # ",\s*$user" -> ""
598 sub B:remove_user_from_group($$) {
600 my ($user_to_remove,$group) = @_;
603 # We need to find the line from /etc/group that defines the group, parse
607 # Open the group file
608 unless (open GROUP,&getGlobal('FILE','group')) {
609 …('ERROR',"&B_remove_user_from_group couldn't read /etc/group to remove $user_to_remove from $group…
612 my @lines = <GROUP>;
613 close GROUP;
623 if ($line =~ /^\s*$group\s*:/) {
655 &B_replace_line(&getGlobal('FILE','group'),"^\\s*$group\\s*:",$group_line);
665 # Checks if the given file has the given owner and/or group.
666 # If the given owner is "", checks group only.
667 # If the given group is "", checks owner only.
670 # 1: file has the given owner and/or group
671 # or file exists, and both the given owner and group are ""
672 # 0: file does not has the given owner or group
676 sub B_check_owner_group ($$$){
677 my ($fileName, $owner, $group) = @_;
679 if (-e $fileName) {
691 # Check file group
692 if ($group ne "") {
693 if (getgrnam($group) != $gid) {
709 sub B_is_unowned_file($) {
722 sub B_is_ungrouped_file($){
748 sub B_check_permissions ($$){
753 if (-e $fileName) {
786 # "group"
796 # this sub routine test whether the $user has the specified previlige to $file
799 sub B_permission_test($$$){
802 if (-e $file ) {
830 elsif ( $user =~ /group/) {
873 sub B_find_homes(){
876 my @lines = `$logins -ox`;
901 sub B_is_executable($)
906 if (-x $name) {
915 # This routine reports on whether a file is Set-UID and owned by root.
923 sub B_is_suid($)
930 if (-u $name) #Checks existence and suid
943 # This routine reports on whether a file is SGID and group owned by
944 # group root (gid 0).
952 sub B_is_sgid($)
959 if (-g $name) #checks existence and sgid
976 sub B_get_user_list()
997 sub B_get_group_list()
1000 open(GROUP,&getGlobal('FILE','group'));
1001 while(my $group_line = <GROUP>) {
1025 sub B:remove_suid($) {
1034 if(-e $file){
1041 my $new_perm = ((($old_perm_raw/512) % 8 ) - 4) .