Browse code

new UsrLoc commands introduced

Jiri Kuthan authored on 28/08/2002 23:43:31
Showing 1 changed files
... ...
@@ -92,8 +92,9 @@ usage:
92 92
  $CMD acl grant <user> <group> ........ grant user membership (*)
93 93
  $CMD acl revoke <user> [<group>] ..... grant user membership(s) (*)
94 94
            < usrloc >
95
- $CMD dul <name> ...................... delete user's UsrLoc entries (*)
95
+ $CMD dul <table> <name> .............. delete user's UsrLoc entries (*)
96 96
  $CMD show [<name>] ................... show online users
97
+ $CMD showdb [<name>] ................. show online users flushed in DB
97 98
  $CMD passwd <user> <passwd> .......... change user's password (*)
98 99
  $CMD perm <user> <uri> ............... introduce a permanent UrLoc entry
99 100
            < server health >
... ...
@@ -118,6 +119,53 @@ prompt_pw() {
118 119
 	fi
119 120
 }
120 121
 
122
+ul_dump()
123
+{
124
+	name=ser_receiver_$$
125
+	path=/tmp/$name
126
+	if [ ! -w $SER_FIFO ]; then
127
+		echo "Error opening ser's FIFO $SER_FIFO"
128
+		echo "Make sure you have line fifo=$SER_FIFO in your config"
129
+		exit 1
130
+	fi
131
+	mkfifo $path
132
+	if [ $? -ne 0 ] ; then
133
+		echo "error opening read fifo $path"
134
+		exit 1
135
+	fi
136
+	cat > $SER_FIFO <<EOF
137
+:ul_dump:$name
138
+
139
+EOF
140
+	cat < $path
141
+	rm $path
142
+}
143
+
144
+ul_rm() # params: <table> <username>
145
+{
146
+	name=ser_receiver_$$
147
+	path=/tmp/$name
148
+	if [ ! -w $SER_FIFO ]; then
149
+		echo "Error opening ser's FIFO $SER_FIFO"
150
+		echo "Make sure you have line fifo=$SER_FIFO in your config"
151
+		exit 1
152
+	fi
153
+	mkfifo $path
154
+	if [ $? -ne 0 ] ; then
155
+		echo "error opening read fifo $path"
156
+		exit 1
157
+	fi
158
+	cat > $SER_FIFO <<EOF
159
+:ul_rm:$name
160
+$1
161
+$2
162
+
163
+EOF
164
+	cat < $path
165
+	rm $path
166
+}
167
+
168
+
121 169
 # $1 = name $2=path $3=attempt
122 170
 print_stats() {
123 171
 
... ...
@@ -425,26 +473,13 @@ case $1 in
425 473
 
426 474
 
427 475
 	dul)
476
+		shift
428 477
 		if [ $# -ne 2 ] ; then
429 478
 			usage
430 479
 			exit 1
431 480
 		fi
432
-		prompt_pw
433
-		QUERY="select count(*) from $USRLOC \
434
-			where $USRLOC.$USER_COLUMN='$2';"
435
-		CNT=`sql_query "$QUERY" "-B" | grep -v ERROR | tail -n1`
436
-		if [ "0$CNT" -eq 0 ] ; then
437
-			echo Nothing to delete
438
-			exit 1
439
-		fi
440
-		QUERY="delete from $USRLOC where $USRLOC.$USER_COLUMN='$2'"
441
-		sql_query "$QUERY"
442
-		if [ $? -ne 0 ] ; then
443
-			echo "database operation failed"
444
-		else
445
-			echo "ok -- but beware, the server caches the usrloc entries"
446
-			echo "and the changes don't take effect until ser reboot"
447
-		fi
481
+		ul_rm $1 $2
482
+		exit $?
448 483
 		;;
449 484
 
450 485
 	monitor|console|moni|con)
... ...
@@ -497,8 +532,13 @@ case $1 in
497 532
 
498 533
 		;;
499 534
 
535
+	show)
536
+		ul_dump
537
+		exit $?
538
+		;;
539
+
500 540
 
501
-	show|user)
541
+	showdb|userdb)
502 542
 		if [ $# -eq 2 ] ; then
503 543
 			is_user $2
504 544
 			if [ $? -ne 0 ] ; then