diff options
Diffstat (limited to 'src/init')
| -rwxr-xr-x | src/init | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -28,10 +28,7 @@ function setupUser set -l key $userConfig[2] # validate username - if not string match -q -r -- $_USER_VALIDATION_REGEX "$user" - echo "Error: User '$user' does not match validation regex" - return 1 - end + checkUsername "$user"; or return $status echo "Setting up user: $user" if [ "$user" = git ] @@ -59,6 +56,17 @@ function setupUser chmod -R 700 "$HOME" end +function checkUsername + set -l user "$argv[1]" + # validate username + if not string match -q -r -- "^$_USER_VALIDATION_REGEX\$" "$user" + echo "Error: User '$user' does not match validation regex" + return 1 + end + + return 0 +end + function setupGitUser doesUserExist "git"; and return 0 echo "Setting up git user" @@ -92,7 +100,11 @@ function setupRepo set -l parsedConfig (string split ':' -- $userConfig) set -l user $parsedConfig[1] set -l permission $parsedConfig[2] - + + if not checkUsername "$user" + continue + end + # check for valid permission if not contains $permission $_PERMISSIONS set permission "r" |
