Setting umask and ulimit values for SAS® sessions on UNIX and Linux


In many circumstances, it might be desirable to control the permissions of files created from SAS sessions, or to set process limits for SAS sessions. For users with SAS® 9 or later, this is fairly straightforward.

To set permissions on files created from SAS sessions on UNIX, the umask command can be issued. The ulimit command is used to set process limits. The location from which these commands are executed will affect the scope of the settings.

These commands can be placed in the following locations:
When submitted for the Workspace Server, or from sasenv_local, the settings can be set for all users, or values can be set conditionally for each user, collections of users, or for all members of a given UNIX group. The only real difference will be how complicated the scripting logic will be to assign the values from the commands.

For example, the following umask command creates all files for all users with effective permissions of
rw-r--r-- (owner:read and write; group:read; other:read):

umask 022

To submit the command only for the user joe00001, this could become as follows:

if [ "$LOGNAME" = joe00001 ]
then
umask 022
fi

The ulimit command can be handled similarly, and can be set differently based on userid or group membership:

# determine primary group membership of user
GP=`groups $LOGNAME | awk '{ print $1 }'`
#
# assign new ulimit based on userid or group membership as desired
#
if [ "$LOGNAME" = joe00001 ]
then
MAXSIZE=4096
umask 022
elif [ "$LOGNAME" = fred0002 -o "$GP" = saspower ]
then
MAXSIZE=8192
umask 077
elif [ "$GP" = sasuser ]
then
MAXSIZE=6144
else
MAXSIZE=8192
fi
export MAXSIZE
ulimit -f $MAXSIZE

Note that SAS Technical Support cannot provide assistance with creating site-specific scripts. Your UNIX system administrator can and should be able to help you with this task.