Orb*_*bit 5

来自最初帖子的代码似乎已经消失了......卷起一个例子.

#!/bin/bash

function mod {
    if [ -d "/Users/$1/share" ]; then
        echo "permissions changes for $1"
        #chmod 750 /Users/$1/share
        #find /Users/$1/share -type f -exec chmod 744 {} \;
        #find /Users/$1/share -type d -exec chmod 750 {} \;
        #find /Users/$1/ -type f -exec chmod 600 {} \;
        #find /Users/$1/ -type d -exec chmod 700 {} \;
    fi   
}

function clean {
    IFS=':' read -ra pw <<< "$1"
    local c=0
    local n=""
    local t=500
    for i in "${pw[@]}"; do 
        if [ $c == 0 ]; then
            n="$i"
        fi
        if [ $c == 2 ]; then
            if [ "$i" -gt "$t" ]; then
                mod $n
            fi
        fi
        c=$[$c+1]
    done
}

function report {
    export user=$(whoami)
    ls -la "/Users/$user" > report.txt
}

if [ -z $1 ]; then"
    while read line; do 
        if [ "${line:0:1}" != "#" ]; then
            clean $line
        fi
    done < /etc/passwd
else
    for arg in "$@"
       do
         mod $arg
       done
fi
report
Run Code Online (Sandbox Code Playgroud)

只有它不符合的要求是在报告的#3下打印完整路径(仅打印相对).变量t是权限更改将影响的最低uid.注释掉chmods所以没有人不小心对他们的系统这样做.哎呀.