[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#392605: mldonkey-server: mldonkey_server fails with uncaught exception



Package: mldonkey-server
Version: 2.8.1-1
Severity: normal
Tags: patch

Here is an example (trying to give a UID instead of a username):
    # mldonkey --chuid 1000
    Fatal error: exception Not_found
The same can happen with --chgid and --umask. The exception is not very
expressive.

Arg.parse is used to parse the command line but this function does not
intercept all exceptions, so a "conversion" has to be made. The proposed
patch:

--- mldonkey-2.8.1/debian/utils/mldonkey_server.ml.orig 2006-10-12
08:53:17.000000000 +0200
+++ mldonkey-2.8.1/debian/utils/mldonkey_server.ml      2006-10-12
09:46:48.000000000 +0200
@@ -181,7 +181,8 @@
     "--chuid",
     Arg.String (fun x ->
                   let passwd_ent =
-                    Unix.getpwnam x
+                    try Unix.getpwnam x with
+                      Not_found -> raise (Arg.Bad ("wrong argument
`"^x^"'; option `--chuid' expects a user name"))
                   in
                     state := {!state with chuid = passwd_ent.pw_uid}
     ),
@@ -189,13 +190,18 @@
     "--chgid",
     Arg.String (fun x ->
                   let group_ent =
-                    Unix.getgrnam x
+                    try Unix.getgrnam x with
+                      Not_found -> raise (Arg.Bad ("wrong argument
`"^x^"'; option `--chgid' expects a group name"))
                   in
                     state := {!state with chgid = group_ent.gr_gid}
     ),
     "Which group own the process";
     "--umask",
-    Arg.String (fun x -> state := {!state with umask = int_of_string (
"0o"^x )}),
+    Arg.String (fun x ->
+                  let mask =
+                    try int_of_string ( "0o"^x ) with
+                      Failure "int_of_string"|| -> raise (Arg.Bad
("wrong argument `"^x^"'; option `--umask' expects an octal umask"))
+                  in state := {!state with umask = mask}),
     "What umask to use";
     "--nice",
     Arg.Int (fun x -> state := {!state with nice = x}),




Reply to: