From 27c39948ca380ab51ef33c0bd988077758889d74 Mon Sep 17 00:00:00 2001 From: oblique Date: Thu, 16 Apr 2015 19:47:45 +0300 Subject: [PATCH] Make --list to work from any user --- create_ap | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/create_ap b/create_ap index 2563337..beb155b 100755 --- a/create_ap +++ b/create_ap @@ -21,6 +21,10 @@ PROGNAME="$(basename $0)" # so we can parse them correctly export LC_ALL=C +# all new files and directories must be readable only by root. +# in special cases we must use chmod to give any other permissions. +umask 0077 + usage() { echo "Usage: "$PROGNAME" [options] [] [ []]" echo @@ -719,6 +723,11 @@ if [[ $# -lt 1 && $FIX_UNMANAGED -eq 0 && -z "$STOP_ID" && $LIST_RUNNING -eq 0 exit 1 fi +if [[ $LIST_RUNNING -eq 1 ]]; then + list_running + exit 0 +fi + if [[ $(id -u) -ne 0 ]]; then echo "You must run it as root." >&2 exit 1 @@ -729,11 +738,6 @@ if [[ -n "$STOP_ID" ]]; then exit 0 fi -if [[ $LIST_RUNNING -eq 1 ]]; then - list_running - exit 0 -fi - if [[ $FIX_UNMANAGED -eq 1 ]]; then networkmanager_fix_unmanaged exit 0 @@ -935,6 +939,11 @@ echo "Config dir: $CONFDIR" echo "PID: $$" echo $$ > $CONFDIR/pid +# to make --list work from any user, we must give read +# permitions to $CONFDIR and $CONFDIR/pid +chmod 755 $CONFDIR +chmod 444 $CONFDIR/pid + if [[ $NO_VIRT -eq 0 ]]; then VWIFI_IFACE=$(get_virt_iface_name)