# linuxSetUserSpaceRestrictions.pl # # by Dean Giles and Austin Giles # Version 1.0 # Febuary 8, 2008 # # This Perl script Sets the user space restrictions for a supplied user DN to a specified volume. # # This script has been designed to be run on Linux. # The API set can be downloaded from http://developer.novell.com/wiki/index.php/Virtual_File_Services_for_NetWare. # # The Perl script requires the name of an NSS pool, a storage pool, and the name of the new snapshot # as input. It requires that NSS be installed and an NSS pool be present. # { # User help function if (@ARGV < 3 || $ARGV[0] eq "/?" || $ARGV[0] eq "-?") { print "USAGE: perl linuxSetUserSpaceRestrictions.pl VOLUME_NAME USER_NAME QUOTA_SIZE\n"; print "Where VOLUME_NAME is the name of a volume on the server. \n"; print "Where USER_NAME is the dot delimited name of the user that will get the volume restriction.\n"; print "Where QUOTA_SIZE is the size of the quota in bytes that will pertain to the specified user.\n"; print "Example: perl linuxSetUserSpaceRestrictions.pl VOL1 user.novell 2000000\n"; print "this will set the user space restrictions for a supplied user DN to a specified volume\n"; exit; } # Global Variables $volumeName = $ARGV[0]; $userName = $ARGV[1]; $quota = $ARGV[2]; $file = "+". "". "". "". "$volumeName". "$userName". "$quota". "". "". ""; # This is the command for initializing the virtual file for sending a command. print "File Name: $file \n"; print "Request Sent: $command \n"; if (!syswrite(NSSFILE, $command, length($command))) #Initialize the nss management file and write a command. { seek NSSFILE, 0, 0; # Make sure to start at the beginning of the file. sysread (NSSFILE, $error, 10000); #Read the error message. print "Error writing initialization to management file. \n"; print "$error \n\n"; #Print the error message to the screen. close (NSSFILE); } else { seek NSSFILE, 0, 0; # Make sure to start at the beginning of the file. sysread (NSSFILE, $reply, 10000); #Read the reply. print "$reply \n\n"; #Print the reply to the screen. close (NSSFILE); } }