tinycm rev 102

new way to handle admin user (faster)
author Christophe Lincoln <pankso@slitaz.org>
date Mon Feb 20 17:03:32 2017 +0100 (2017-02-20)
parents 35354740250d
children aebfa2a5c127
files config.cgi index.cgi plugins/users/users.cgi tinycm
line diff
     1.1 --- a/config.cgi	Mon Feb 20 14:36:57 2017 +0100
     1.2 +++ b/config.cgi	Mon Feb 20 17:03:32 2017 +0100
     1.3 @@ -8,6 +8,9 @@
     1.4  # Auth file for user
     1.5  AUTH_FILE="/var/lib/slitaz/auth/people"
     1.6  
     1.7 +# Admin users file list
     1.8 +ADMIN_USERS="/var/lib/slitaz/auth/admin"
     1.9 +
    1.10  # People config files
    1.11  PEOPLE="/var/lib/slitaz/people"
    1.12  
     2.1 --- a/index.cgi	Mon Feb 20 14:36:57 2017 +0100
     2.2 +++ b/index.cgi	Mon Feb 20 17:03:32 2017 +0100
     2.3 @@ -152,7 +152,7 @@
     2.4  
     2.5  # Check if user is admin
     2.6  admin_user() {
     2.7 -	fgrep -q 'ADMIN_USER="yes"' ${PEOPLE}/${user}/account.conf
     2.8 +	fgrep -w -q "$user" ${ADMIN_USERS}
     2.9  }
    2.10  
    2.11  # Authenticated or not
     3.1 --- a/plugins/users/users.cgi	Mon Feb 20 14:36:57 2017 +0100
     3.2 +++ b/plugins/users/users.cgi	Mon Feb 20 17:03:32 2017 +0100
     3.3 @@ -71,17 +71,19 @@
     3.4  <h3>Config paths</h3>
     3.5  <pre>
     3.6  People DB       : $PEOPLE
     3.7 -Auth file       : $AUTH_FILE
     3.8 +Authfile        : $AUTH_FILE
     3.9 +Admin users     : $ADMIN_USERS
    3.10  </pre>
    3.11  EOT
    3.12  				# Get the list of administrators
    3.13  				echo "<h3>Admin users</h3>"
    3.14 -				fgrep -l "ADMIN_USER=" $PEOPLE/*/account.conf | while read file;
    3.15 +				echo "<pre>"
    3.16 +				for u in $(cat $ADMIN_USERS)
    3.17  				do
    3.18 -					. ${file}
    3.19 -					echo "<a href='?user=$USER'>$USER</a>"
    3.20 -					unset NAME USER
    3.21 +					. ${PEOPLE}/${u}/account.conf
    3.22 +					echo "<a href='?user=$u'>$u</a> | $NAME"
    3.23  				done
    3.24 +				echo "</pre>"
    3.25  			fi
    3.26  			
    3.27  		else
     4.1 --- a/tinycm	Mon Feb 20 14:36:57 2017 +0100
     4.2 +++ b/tinycm	Mon Feb 20 17:03:32 2017 +0100
     4.3 @@ -59,8 +59,11 @@
     4.4  update_config() {
     4.5  	echo "Updating config file: confi.cgi"
     4.6  	. ${path}/config.cgi
     4.7 +	# Def value for new variables
     4.8  	[ ! "$WALL_MODE" ] && WALL_MODE="public"
     4.9  	[ ! "$WALL_MESSAGES_LENGTH" ] && WALL_MESSAGES_LENGTH="240"
    4.10 +	# from 1.4
    4.11 +	[ ! "$ADMIN_USERS" ] && ADMIN_USERS=$(dirname "$AUTH_FILE")/admin
    4.12  	cat > ${path}/config.cgi << EOT
    4.13  #
    4.14  # TinyCM configuration
    4.15 @@ -72,6 +75,9 @@
    4.16  # Auth file for user
    4.17  AUTH_FILE="$AUTH_FILE"
    4.18  
    4.19 +# Admin users file list
    4.20 +ADMIN_USERS="/var/lib/slitaz/auth/admin"
    4.21 +
    4.22  # People config files
    4.23  PEOPLE="$PEOPLE"
    4.24