-
Notifications
You must be signed in to change notification settings - Fork 1
Whm/volcreate acls #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| $VERSION = '2.8 (2025-07-01)'; | ||
| $VERSION = '2.9 (2025-08-18)'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| #!/usr/bin/perl | ||
| our $VERSION = '2.8 (2025-07-01)'; | ||
| our $VERSION = '2.9 (2025-08-18)'; | ||
| # | ||
| # volcreate -- Create a volume, mount and set acl and quota | ||
| # | ||
|
|
@@ -13,7 +13,7 @@ our $VERSION = '2.8 (2025-07-01)'; | |
| # The Board of Trustees of the Leland Stanford Junior University | ||
| # | ||
| # Updated by Bill MacAllister <bill@ca-zephyr.org> | ||
| # Copyright 2018 | ||
| # Copyright 2018-2025 | ||
| # Bill MacAllister <bill@ca-zephyr.org> | ||
| # | ||
| # This program is free software; you may redistribute it and/or modify it | ||
|
|
@@ -286,14 +286,60 @@ sub find_best_replicated { | |
| return @locations; | ||
| } | ||
|
|
||
| # Set the ACLs of the volume appropriately. Some volumes have their own | ||
| # particular ACL conventions; take care of those here as well. | ||
| sub get_acl_list { | ||
| my ($volume, @acls) = @_; | ||
|
|
||
| # Find any extra ACLs that apply to this volume. | ||
| my @extra; | ||
| if (open(ACLS, '<', $ACLS)) { | ||
| my $found = 0; | ||
| while (<ACLS>) { | ||
| chomp; | ||
| my $inline = $_; | ||
| if ($inline =~ /^\s+\#/) { | ||
| next; | ||
| } | ||
| if ($inline =~ /^\s*$/) { | ||
| next; | ||
| } | ||
| if ($inline =~ m%^/(.*)/\s*$%) { | ||
| my $regex = $1; | ||
| if ($volume =~ /$regex/) { | ||
| $found = 1; | ||
| } | ||
| } elsif ($found && $inline =~ /^\s/) { | ||
| my ($user, $acl, $bogus) = split; | ||
| if ($bogus || !$user || !$acl) { | ||
| warn "$0: syntax error on line $. of $ACLS\n"; | ||
| next; | ||
| } | ||
| push(@extra, $user, $acl); | ||
| } | ||
| } | ||
| close ACLS; | ||
| } else { | ||
| warn "$0: cannot open $ACLS: $!\n"; | ||
| } | ||
|
|
||
| # Append the extra ACLs that apply to this volume. | ||
| push(@acls, @extra); | ||
|
|
||
| return @acls; | ||
| } | ||
|
|
||
| ############################################################################## | ||
| # AFS operations | ||
| ############################################################################## | ||
|
|
||
| # Create a volume, given the server, partition, volume name, and quota. Dies | ||
| # on a failure to create the volume. | ||
| sub volume_create { | ||
| my ($server, $partition, $volume, $quota) = @_; | ||
| my ($server, $partition, $volume, $quota, @acls) = @_; | ||
|
|
||
| my @cmd = (); | ||
|
|
||
| my $quota_kbytes; | ||
| if ($quota =~ /^(\d+)$/xms) { | ||
| $quota_kbytes = $quota * 1024; | ||
|
|
@@ -314,14 +360,31 @@ sub volume_create { | |
| die "ERROR: invalid quota value ($quota)\n"; | ||
| } | ||
|
|
||
| system( | ||
| $VOS, 'create', '-server', $server, | ||
| '-partition', $partition, '-name', $volume, | ||
| '-maxquota', $quota_kbytes | ||
| ) == 0 | ||
| or die 'Failed to create volume (status ', ($? >> 8), ")\n"; | ||
| system($VOS, 'backup', '-id', $volume) == 0 | ||
| or die 'Failed to backup volume (status ', ($? >> 8), ")\n"; | ||
| @cmd = ($VOS, 'create'); | ||
| push(@cmd, '-server', $server); | ||
| push(@cmd, '-partition', $partition); | ||
| push(@cmd, '-name', $volume); | ||
| push(@cmd, '-maxquota', $quota_kbytes); | ||
| if (system(@cmd)) { | ||
| die 'Failed to create volume (status ', ($? >> 8), ")\n"; | ||
| } | ||
|
|
||
| @cmd = ($VOS, 'backup', '-id', $volume); | ||
| if (system(@cmd)) { | ||
| die 'Failed to backup volume (status ', ($? >> 8), ")\n"; | ||
| } | ||
|
|
||
| # Set the acls on the volume | ||
| my @this_acl_list = get_acl_list($volume, @acls); | ||
| if (scalar(@this_acl_list) > 0) { | ||
| @cmd = ($VOS, 'setrootacl'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is setting the volume root directory acl. Should "volcreate" also provide for an option of setting the volume maximum acl? Should "volcreate" also permit the volume owner to be assigned? "vos setowner". The volume owner is a "pts id" (user or group). The volume owner is permitted to fetch the contents of all directories, symlinks and mountpoints. The volume owner may also modify ACLs on all objects in the volume. |
||
| push(@cmd, '-id', $volume); | ||
| push(@cmd, '-acl', @this_acl_list); | ||
| if (system(@cmd)) { | ||
| warn 'Failed to set acls (status ', ($? >> 8), ")\n"; | ||
| } | ||
| } | ||
|
|
||
| return; | ||
| } | ||
|
|
||
|
|
@@ -580,12 +643,9 @@ if ($type) { | |
| if ($clone) { | ||
| volume_clone($server, $partition, $volume, $clone); | ||
| } else { | ||
| volume_create($server, $partition, $volume, $quota); | ||
| volume_create($server, $partition, $volume, $quota, @acls); | ||
| } | ||
| volume_mount($volume, $mtpt); | ||
| if (!$clone) { | ||
| volume_setacls($volume, $mtpt, @acls); | ||
| } | ||
|
|
||
| # If the volume is replicated, take care of creating and releasing the | ||
| # replicas now that the ACL is set correctly. | ||
|
|
@@ -946,7 +1006,7 @@ Updated with Auristor support by Bill MacAllister <bill@ca-zephyr.org>. | |
| Copyright 1998, 1999, 2000, 2002, 2004, 2005, 2011 The Board of Trustees | ||
| of the Leland Stanford Junior University. | ||
|
|
||
| Copyright 2018 Bill MacAllister <bill@ca-zephyr.org> | ||
| Copyright 2018-2025 Bill MacAllister <bill@ca-zephyr.org> | ||
|
|
||
| This program is free software; you may redistribute it and/or modify it | ||
| under the same terms as Perl itself. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the backup volume is created before the setting of the optional root acls, then the created .backup will not be protected by those acls.