[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Mldonkey-commits] mldonkey config/Makefile.in distrib/ChangeLog s...
From: |
mldonkey-commits |
Subject: |
[Mldonkey-commits] mldonkey config/Makefile.in distrib/ChangeLog s... |
Date: |
Sun, 26 Feb 2006 16:23:56 +0000 |
CVSROOT: /sources/mldonkey
Module name: mldonkey
Branch:
Changes by: spiralvoice <address@hidden> 06/02/26 16:23:55
Modified files:
config : Makefile.in
distrib : ChangeLog
src/daemon/common: commonGlobals.ml commonOptions.ml
src/daemon/driver: driverCommands.ml driverControlers.ml
driverInteractive.ml driverInterface.ml
Added files:
src/daemon/common: commonUserDb.ml
Log message:
patch #4938
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/config/Makefile.in.diff?tr1=1.150&tr2=1.151&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/distrib/ChangeLog.diff?tr1=1.751&tr2=1.752&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonGlobals.ml.diff?tr1=1.60&tr2=1.61&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonOptions.ml.diff?tr1=1.128&tr2=1.129&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonUserDb.ml?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml.diff?tr1=1.125&tr2=1.126&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverControlers.ml.diff?tr1=1.62&tr2=1.63&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverInteractive.ml.diff?tr1=1.66&tr2=1.67&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverInterface.ml.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
Patches:
Index: mldonkey/config/Makefile.in
diff -u mldonkey/config/Makefile.in:1.150 mldonkey/config/Makefile.in:1.151
--- mldonkey/config/Makefile.in:1.150 Sat Feb 11 19:52:57 2006
+++ mldonkey/config/Makefile.in Sun Feb 26 16:23:55 2006
@@ -227,6 +227,7 @@
$(COMMON)/guiProto.ml \
$(COMMON)/commonEvent.ml \
$(COMMON)/commonOptions.ml \
+ $(COMMON)/commonUserDb.ml \
$(COMMON)/commonMessages.ml \
$(COMMON)/commonGlobals.ml \
$(COMMON)/commonBitzi.ml \
Index: mldonkey/distrib/ChangeLog
diff -u mldonkey/distrib/ChangeLog:1.751 mldonkey/distrib/ChangeLog:1.752
--- mldonkey/distrib/ChangeLog:1.751 Sun Feb 26 15:51:41 2006
+++ mldonkey/distrib/ChangeLog Sun Feb 26 16:23:55 2006
@@ -14,6 +14,9 @@
ChangeLog
=========
+2006/02/26
+4938: Improve MLDonkey system user database
+-------------------------------------------------------------------------------
2006/02/26: version 2.7.4 = tag release-2-7-4
2006/02/25
Index: mldonkey/src/daemon/common/commonGlobals.ml
diff -u mldonkey/src/daemon/common/commonGlobals.ml:1.60
mldonkey/src/daemon/common/commonGlobals.ml:1.61
--- mldonkey/src/daemon/common/commonGlobals.ml:1.60 Sun Dec 18 14:50:38 2005
+++ mldonkey/src/daemon/common/commonGlobals.ml Sun Feb 26 16:23:55 2006
@@ -503,14 +503,6 @@
in
iter !ui_users
-
-let valid_password user pass =
- let pass = Md4.Md4.string pass in
- try
- let password = List.assoc user !!users in
- password = pass
- with _ -> false
-
(* control_: means that it is the limited bandwidth, not the unlimited one
used by the interfaces. tcp_: the full bandwidth (limited+unlimited) *)
Index: mldonkey/src/daemon/common/commonOptions.ml
diff -u mldonkey/src/daemon/common/commonOptions.ml:1.128
mldonkey/src/daemon/common/commonOptions.ml:1.129
--- mldonkey/src/daemon/common/commonOptions.ml:1.128 Tue Feb 21 07:49:58 2006
+++ mldonkey/src/daemon/common/commonOptions.ml Sun Feb 26 16:23:55 2006
@@ -268,11 +268,9 @@
let empty_password = Md4.string ""
let users = define_option users_section ["users"]
- "The users that are defined on this core. The default user is
-called 'admin', and uses an empty password. To create new users,
-login as admin in mldonkey, and use the 'add_user' command."
+ "old option, kept for compatibility reasons."
(list_option (tuple2_option (string_option, Md4.option)))
- [ "admin", empty_password ]
+ []
let empty_password user =
try
Index: mldonkey/src/daemon/driver/driverCommands.ml
diff -u mldonkey/src/daemon/driver/driverCommands.ml:1.125
mldonkey/src/daemon/driver/driverCommands.ml:1.126
--- mldonkey/src/daemon/driver/driverCommands.ml:1.125 Mon Feb 6 21:47:02 2006
+++ mldonkey/src/daemon/driver/driverCommands.ml Sun Feb 26 16:23:55 2006
@@ -40,6 +40,7 @@
open CommonFile
open CommonComplexOptions
open CommonOptions
+open CommonUserDb
open CommonInteractive
open CommonEvent
@@ -637,45 +638,62 @@
else
_s "Usage: message <client num> <msg>\n";
- ), ":\t\t\t\tmessage [<client num> <msg>]";
+ ), ":\t\t\t\t[<client num> <msg>]";
+ "useradd", Arg_multiple (fun args o ->
+ let buf = o.conn_buf in
+ let print_result o result =
+ if o.conn_output = HTML then
+ html_mods_table_one_row buf "serversTable" "servers" [
+ ("", "srh", result); ]
+ else
+ Printf.bprintf buf "%s" result
+ in
+ let add_new_user user pass mail =
+ if o.conn_user == default_user
+ || o.conn_user == (find_ui_user user) then
+ try
+ ignore (user2_find user);
+ ignore (user2_add user (Md4.string pass) "");
+ print_result o (Printf.sprintf "Password of user %s changed" user)
+ with _ ->
+ ignore (user2_add user (Md4.string pass) "");
+ print_result o (Printf.sprintf "User %s added" user)
+ else
+ print_result o "Only 'admin' is allowed to add users"
+ in begin
+ match args with
+ user :: pass :: mail :: _ ->
+ add_new_user user pass mail
+ | user :: pass :: _ ->
+ add_new_user user pass "";
+ | _ -> print_result o "Wrong syntax: use 'useradd user pass <mail>'"
+ end;
+ _s ""
+ ), "<user> <passwd> [<mail>] :\t\tadd new mldonkey user/change user
password";
- "add_user", Arg_two (fun user pass o ->
- if o.conn_user == default_user
- || o.conn_user == (find_ui_user user) then
- try
- let p = List.assoc user !!users in
- let pass = Md4.string pass in
-(* In place replacement....heurk *)
- String.blit (Md4.direct_to_string pass) 0
- (Md4.direct_to_string p) 0 16;
- _s "Password changed"
- with _ ->
- users =:= (user, Md4.string pass) :: !!users;
- _s "User added"
- else
- _s "Only 'admin' is allowed to add users"
- ), "<user> <passwd> :\t\tadd new mldonkey user/change user password";
-
- "remove_user", Arg_one (fun user o ->
+ "userdel", Arg_one (fun user o ->
+ let buf = o.conn_buf in
+ let print_result o result =
+ if o.conn_output = HTML then
+ html_mods_table_one_row buf "serversTable" "servers" [
+ ("", "srh", result); ]
+ else
+ Printf.bprintf buf "%s" result
+ in
if o.conn_user == default_user then
if user = "admin" then
- _s "User 'admin' can not be removed"
+ print_result o "User 'admin' can not be removed"
else
- begin
- let found = ref false in
- users =:= List.filter (fun (s,_) ->
- let diff = s <> user in
- if not diff then found := true;
- diff
- ) !!users;
- if !found then
- _s (Printf.sprintf "user %s removed" user)
- else
- _s (Printf.sprintf "user %s not found" user)
- end
+ try
+ ignore (user2_find user);
+ ignore (user2_remove user);
+ print_result o (Printf.sprintf "User %s removed" user)
+ with _ ->
+ print_result o (Printf.sprintf "User %s not found" user)
else
- _s "Only 'admin' is allowed to remove users"
+ print_result o "Only 'admin' is allowed to remove users";
+ _s ""
), "<user> :\t\t\tremove a mldonkey user";
@@ -693,7 +711,7 @@
var getdir = prompt('Input: <user> <pass>','user pass')
var reg = new RegExp (' ', 'gi') ;
var outstr = getdir.replace(reg, '+');
- parent.fstatus.location.href='submit?q=add_user+' + outstr;
+ parent.fstatus.location.href='submit?q=useradd+' + outstr;
setTimeout('window.location.reload()',1000);
}\\\"\\>Add User\\</a\\>
\\</td\\>
@@ -707,35 +725,33 @@
let counter = ref 0 in
- List.iter (fun (user,_) ->
+ user2_iter (fun name user ->
incr counter;
Printf.bprintf buf "\\<tr class=\\\"%s\\\"\\>"
(if !counter mod 2 == 0 then "dl-1" else "dl-2");
- if user <> "admin" then Printf.bprintf buf "
+ if user.user_name <> "admin" then Printf.bprintf buf "
\\<td title=\\\"Click to remove user\\\"
onMouseOver=\\\"mOvr(this);\\\"
onMouseOut=\\\"mOut(this);\\\"
onClick=\\\'javascript:{
-
parent.fstatus.location.href=\\\"submit?q=remove_user+\\\\\\\"%s\\\\\\\"\\\";
+
parent.fstatus.location.href=\\\"submit?q=userdel+\\\\\\\"%s\\\\\\\"\\\";
setTimeout(\\\"window.location.reload()\\\",1000);}'
- class=\\\"srb\\\"\\>Remove\\</td\\>" user
+ class=\\\"srb\\\"\\>Remove\\</td\\>" user.user_name
else Printf.bprintf buf "
\\<td title=\\\"\\\"
class=\\\"srb\\\"\\>------\\</td\\>";
Printf.bprintf buf
- "\\<td class=\\\"sr\\\"\\>%s\\</td\\>\\</tr\\>" user
- )
- !!users;
+ "\\<td class=\\\"sr\\\"\\>%s\\</td\\>\\</tr\\>" user.user_name
+ );
Printf.bprintf buf
"\\</table\\>\\</td\\>\\<tr\\>\\</table\\>\\</div\\>";
end
else
begin
Printf.bprintf buf "Users:\n";
- List.iter (fun (user,_) ->
+ user2_iter (fun name user ->
Printf.bprintf buf " %s\n"
- user)
- !!users;
+ user.user_name);
end;
""
else
@@ -745,17 +761,12 @@
"whoami", Arg_none (fun o ->
let buf = o.conn_buf in
let whoami = o.conn_user.ui_user_name in
- if o.conn_output = HTML then
- begin
- Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>";
- html_mods_table_header buf "versionTable" "results" [];
- Printf.bprintf buf "\\<tr\\>";
- html_mods_td buf [ ("", "srh", whoami); ];
- Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>";
- end
+ if use_html_mods o then
+ html_mods_table_one_row buf "serversTable" "servers" [
+ ("", "srh", whoami); ]
else
- Printf.bprintf buf "%s" whoami;
- ""
+ Printf.bprintf buf "%s" whoami;
+ _s ""
), ":\t\t\t\tprint logged-in user name";
"calendar_add", Arg_two (fun hour action o ->
@@ -1133,8 +1144,8 @@
Printf.bprintf buf
"\\</tr\\>\\</table\\>\\</td\\>\\</tr\\>\\</table\\>\\</div\\>";
- Printf.bprintf buf "\\<script
type=\\\"text/javascript\\\"\\>window.parent.document.title='(D:%.1f) (U:%.1f)
| %s'\\</script\\>"
- dlkbs ulkbs (CommonGlobals.version ())
+ Printf.bprintf buf "\\<script
type=\\\"text/javascript\\\"\\>window.parent.document.title='(D:%.1f) (U:%.1f)
| %s | %s'\\</script\\>"
+ dlkbs ulkbs o.conn_user.ui_user_name (CommonGlobals.version ())
end
else
DriverInteractive.print_bw_stats buf;
Index: mldonkey/src/daemon/driver/driverControlers.ml
diff -u mldonkey/src/daemon/driver/driverControlers.ml:1.62
mldonkey/src/daemon/driver/driverControlers.ml:1.63
--- mldonkey/src/daemon/driver/driverControlers.ml:1.62 Sun Feb 5 13:25:22 2006
+++ mldonkey/src/daemon/driver/driverControlers.ml Sun Feb 26 16:23:55 2006
@@ -35,6 +35,7 @@
open DriverGraphics
open DriverInteractive
open CommonOptions
+open CommonUserDb
(* prints a new logline with date, module and starts newline *)
let lprintf_nl () =
@@ -1419,7 +1420,6 @@
| "vd" | "vo" | "voo" | "upstats" | "shares" | "share"
| "unshare" | "stats" | "users" -> drop_pre := true;
| _ -> ());
-
Printf.bprintf buf "%s\n"
(if use_html_mods o && !drop_pre then s else "\n<pre>\n" ^
s ^ "</pre>");
Index: mldonkey/src/daemon/driver/driverInteractive.ml
diff -u mldonkey/src/daemon/driver/driverInteractive.ml:1.66
mldonkey/src/daemon/driver/driverInteractive.ml:1.67
--- mldonkey/src/daemon/driver/driverInteractive.ml:1.66 Tue Feb 21
08:23:12 2006
+++ mldonkey/src/daemon/driver/driverInteractive.ml Sun Feb 26 16:23:55 2006
@@ -34,6 +34,7 @@
open CommonTypes
open CommonGlobals
open CommonOptions
+open CommonUserDb
open CommonTypes
open Int64ops
@@ -48,24 +49,19 @@
(log_time ()); lprintf
let verify_user_admin () =
+ let empty_pwd = ref false in
+ begin try
+ if user2_password "admin" = Md4.string "" then
+ empty_pwd := true
+ with e ->
+ lprintf_nl () "SECURITY INFO: user 'admin' has to be present,
creating...";
+ empty_pwd := true;
+ ignore (user2_add "admin" blank_password "")
+ end;
let warning =
- "SECURITY WARNING: user admin has an empty password, use command: add_user
admin password\n"
+ "SECURITY WARNING: user admin has an empty password, use command: useradd
admin password\n"
in
- let found = ref false in
- let empty_password = ref false in
- List.iter (fun (user,pass) ->
- if user = "admin" then begin
- found := true;
- if pass = Md4.string "" then
- empty_password := true
- end
- ) !!users;
- if not !found then begin
- lprintf_nl () "SECURITY INFO: user 'admin' has to be present, creating...";
- users =:= ("admin", Md4.string "") :: !!users;
- empty_password := true
- end;
- if !empty_password && not !!enable_user_config then
+ if !empty_pwd && not !!enable_user_config then
begin
lprintf_n () "%s" warning;
warning
@@ -1745,7 +1741,7 @@
let s =
(
"User:\t\t " ^ ui_user
- ^ (if List.assoc ui_user !!users = Md4.string "" then " (Warning:
empty Password)"
+ ^ (if empty_password ui_user then " (Warning: empty Password)"
else " (PW Protected)")
^ " - uptime: " ^ Date.time_to_string (last_time () -
start_time) "verbose"
^ "\nEnabled nets:\t"
Index: mldonkey/src/daemon/driver/driverInterface.ml
diff -u mldonkey/src/daemon/driver/driverInterface.ml:1.39
mldonkey/src/daemon/driver/driverInterface.ml:1.40
--- mldonkey/src/daemon/driver/driverInterface.ml:1.39 Fri Feb 3 21:01:43 2006
+++ mldonkey/src/daemon/driver/driverInterface.ml Sun Feb 26 16:23:55 2006
@@ -40,7 +40,8 @@
open TcpBufferedSocket
open CommonOptions
open CommonGlobals
-
+open CommonUserDb
+
module P = GuiProto
let lprintf_nl () =
lprintf "%s[dIface] "