[Pkg-ocaml-maint-commits] r1409 - in trunk/packages/mldonkey/trunk/debian: . utils xml-man
Sylvain LE GALL
gildor-guest@costa.debian.org
Wed, 22 Jun 2005 22:18:55 +0000
Author: gildor-guest
Date: 2005-06-22 22:18:55 +0000 (Wed, 22 Jun 2005)
New Revision: 1409
Modified:
trunk/packages/mldonkey/trunk/debian/README.Debian
trunk/packages/mldonkey/trunk/debian/TODO
trunk/packages/mldonkey/trunk/debian/changelog
trunk/packages/mldonkey/trunk/debian/utils/mldonkey_server.ml
trunk/packages/mldonkey/trunk/debian/xml-man/mldonkey_server.xml
Log:
Add option to manage niceness, update the man pages of mldonkey_server, minor correction to README.Debian -- SLG
Modified: trunk/packages/mldonkey/trunk/debian/README.Debian
===================================================================
--- trunk/packages/mldonkey/trunk/debian/README.Debian 2005-06-22 14:36:41 UTC (rev 1408)
+++ trunk/packages/mldonkey/trunk/debian/README.Debian 2005-06-22 22:18:55 UTC (rev 1409)
@@ -81,6 +81,7 @@
- you change the password with the auth command.
telnet>auth user old-passwd
+ telnet>add_user user new-passwd
telnet>auth user new-passwd
You can also do the same through the GUI by providing at the beginning the
Modified: trunk/packages/mldonkey/trunk/debian/TODO
===================================================================
--- trunk/packages/mldonkey/trunk/debian/TODO 2005-06-22 14:36:41 UTC (rev 1408)
+++ trunk/packages/mldonkey/trunk/debian/TODO 2005-06-22 22:18:55 UTC (rev 1409)
@@ -7,7 +7,6 @@
* Correct bugs :
Grave functionality bugs - outstanding
#279030: mldonkey-server: debconf configuration is entirely ignored
- #299722: mldonkey-server does not start because of /var/run/mldonkey permissions
#300560: mldonkey-server: downloads.ini writable by group users, world-readable
Important bugs - outstanding
@@ -20,7 +19,6 @@
#254000: logs to syslog instead of using own logfiles in /var/log/mldonkey/
#263094: mldonkey: Extra files to distribute
#270371: mldonkey-gui: graphical availablility isn't displayed
- #283930: mldonkey-server package bug. Daemon not able to start due to tmp file left after reboot.
#285202: disconnect mldonkey-server if non-iso8859-1 characters typed in search section
#291451: mldonkey-server: Server not starting after reboot
@@ -29,4 +27,3 @@
Wishlist items - outstanding
#274460: consider packaging KMLDonkey
- #295854: mldonkey-server: Remove lost pid file
Modified: trunk/packages/mldonkey/trunk/debian/changelog
===================================================================
--- trunk/packages/mldonkey/trunk/debian/changelog 2005-06-22 14:36:41 UTC (rev 1408)
+++ trunk/packages/mldonkey/trunk/debian/changelog 2005-06-22 22:18:55 UTC (rev 1409)
@@ -45,10 +45,22 @@
* Modify mldonkey_server:
* Add an option to configure the group that should be used when running
mldonkey.
+ * Add an option to configure the niceness of the process
* Add sanity check :
- * Check for stale pidfile
- * Check for good permission/owner/group of files used by mldonkey
- * Check for stale .tmp file
+ * Check for stale pidfile (Closes: #295854)
+ * Check for good permission/owner/group of files used by mldonkey. After
+ better reading the patch provided in bugs 299722, i decided to replace
+ a "simple" reowning of the pidfile by a complete check of permission
+ and ownership. Reowning a file is not as simple as it looks like. We
+ should take care of "dpkg-statoverride" et al. Moreover, i don't want
+ to autoset things in the init script. If the ownership/permission of
+ files are not good, there should be a real problem (as a standard
+ install should set the good permission). I don't try to hide these
+ problem by doing fix in the init script: i just warn the user. (Closes: #299722).
+ * Check for stale .tmp file (Closes: #283930)
+ * Update the manual page according to these changes.
+ * Correct the way you can change password in README.Debian, thanks to
+ Spiralvoice. (Closes: #312370)
-- Sylvain Le Gall <sylvain.le-gall@polytechnique.org> Wed, 22 Jun 2005 01:11:44 +0200
Modified: trunk/packages/mldonkey/trunk/debian/utils/mldonkey_server.ml
===================================================================
--- trunk/packages/mldonkey/trunk/debian/utils/mldonkey_server.ml 2005-06-22 14:36:41 UTC (rev 1408)
+++ trunk/packages/mldonkey/trunk/debian/utils/mldonkey_server.ml 2005-06-22 22:18:55 UTC (rev 1409)
@@ -16,6 +16,9 @@
type action_type = Start | Stop | Restart
;;
+let (prio_min,prio_max) = (-20,20)
+;;
+
type mldonkey_server_state = {
real_home : string option;
daemon : bool;
@@ -26,8 +29,10 @@
logger : string;
prg_args : string list;
chdir : string option;
- chuid : int * int;
+ chuid : int;
+ chgid : int;
umask : int;
+ nice : int;
action : action_type;
(* Variable to determine the way we manage mlnet *)
@@ -112,8 +117,10 @@
logger = "/usr/bin/logger";
prg_args = [];
chdir = None;
- chuid = (Unix.getuid (), Unix.getgid ());
+ chuid = Unix.getuid ();
+ chgid = Unix.getgid ();
umask = 0o0022;
+ nice = 0;
action = Start;
(* 5 min *)
@@ -201,7 +208,7 @@
let passwd_ent =
Unix.getpwnam x
in
- state := {!state with chuid = (passwd_ent.pw_uid, snd !state.chuid)}
+ state := {!state with chuid = passwd_ent.pw_uid}
),
"Which user own the process"
);
@@ -211,18 +218,25 @@
let group_ent =
Unix.getgrnam x
in
- state := {!state with chuid = (fst !state.chuid, group_ent.gr_gid)}
+ 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 )}
+ state := {!state with umask = int_of_string ( "0o"^x )}
),
"What umask to use"
);
(
+ "--nice",
+ Arg.Int (fun x ->
+ state := {!state with nice = x}
+ ),
+ "Niceness of the process"
+ );
+ (
"--end-duration",
Arg.Int (fun x -> state := {!state with end_duration = float_of_int x }),
"How much time does it take to end mlnet"
@@ -268,7 +282,6 @@
add_args
"Usage mldonkey_server [options] -- [mlnet options] where options are :"
in
- (* TODO: we should check that the corresponding (UID,GID) are coherent *)
!state
;;
@@ -321,26 +334,43 @@
match answer with
"y" ->
Unix.mkdir (get_chdir st) 0o0755;
- debug st ("Creating home dir : "^(get_chdir st))
+ debug st ("Creating home dir: "^(get_chdir st))
| _ ->
raise No_home_to_chdir
end
else
raise No_home_to_chdir
-let set_uid st =
- let (uid,gid) = st.chuid
- in
- debug st ("Set uid/gid of the process ( "^(string_of_int uid)^", "^(string_of_int gid)^" )");
- setgid gid;
- setuid uid
+let set_uid_gid st =
+ debug st (
+ "Set uid/gid of the process ("^(string_of_int st.chuid)
+ ^", "^(string_of_int st.chgid)^")");
+ setgid st.chgid;
+ setuid st.chuid
;;
let set_umask st =
- debug st ("Set umask of the process :"^(string_of_int st.umask));
+ debug st ("Set umask of the process:"^(string_of_int st.umask));
ignore(umask st.umask)
;;
+let set_nice st =
+ debug st ("Set niceness of the process: "^(string_of_int st.nice));
+ (* We are in the bound of the normal niceness *)
+ if prio_min <= st.nice && st.nice <= prio_max then
+ let current_nice = Unix.nice 0
+ in
+ (* Only root can lower the niceness of a process *)
+ if current_nice > st.nice && (Unix.getuid ()) <> 0 then
+ warning st ("Only root can lower the niceness of a process ("
+ ^(string_of_int current_nice)^" > "^(string_of_int st.nice)^")")
+ else
+ ignore (Unix.nice (st.nice - current_nice))
+ else
+ warning st ("Niceness out of bound ("^(string_of_int st.nice)
+ ^"not in ["^(string_of_int prio_min)^"; "^(string_of_int prio_max)^"]")
+;;
+
(** Create a pidfile, holding the PID value of the process *)
let create_pidfile st =
let pidfile = open_out (get_pidfile st)
@@ -418,7 +448,6 @@
(** Get problematic INI file for mldonkey. Returns a list of all problematic
files
*)
-
let check_tmp_ini_files lst_fl =
let check_one_tmp_ini_file lst fl =
let tmp_fl =
@@ -436,7 +465,6 @@
directory/file that could be used by mldonkey. Returns a list of all
problematic files/directories.
*)
-
let check_file_owner_perms (uid,gid) lst_fl =
let check_one_file_owner_perms lst fl =
let match_perm perm perm_to_match =
@@ -476,7 +504,6 @@
is used to check that the file containing password are not readable by the
group "other". Returns a list of problematic files
*)
-
let check_file_security_perms lst_fl =
let check_one_file_security_perms lst fl =
if Sys.file_exists fl then
@@ -516,31 +543,41 @@
in
let inifiles = get_inifiles st
in
+ let basedirs =
+ [
+ get_chdir st;
+ Filename.dirname pidfile
+ ]
+ in
let old_inifiles =
List.map ( fun x -> x ^ ".old" )
inifiles
in
- let (uid,gid) = st.chuid
- in
+ (* Test existence of a few dirs *)
+ check_fun
+ (List.filter (fun fl -> not (Sys.file_exists fl)))
+ basedirs
+ "directory[ies] doesn't exist"
+ "create it first"
+ 1;
check_fun
check_tmp_ini_files
inifiles
"temporary file[s] left"
"delete it first"
1;
- (* TODO: check also the pidfile *)
check_fun
- (check_file_owner_perms (uid,gid))
- (inifiles @ old_inifiles @ passwdfiles)
- ("file[s] not owned by user "^(string_of_int uid)
- ^" or group "^(string_of_int gid))
+ (check_file_owner_perms (st.chuid,st.chgid))
+ (basedirs @ inifiles @ old_inifiles @ passwdfiles)
+ ("file[s] not owned by user "^(string_of_int st.chuid)
+ ^" or group "^(string_of_int st.chgid))
"reown it first"
1;
check_fun
check_file_security_perms
passwdfiles
- ("file[s] should be only readable by owner "^(string_of_int uid)
- ^" or group "^(string_of_int gid))
+ ("file[s] should be only readable by owner "^(string_of_int st.chuid)
+ ^" or group "^(string_of_int st.chgid))
"change permission"
1;
;;
@@ -595,10 +632,10 @@
()
;;
-
let start_mldonkey_server st =
sanity_check st;
- set_uid st;
+ set_nice st;
+ set_uid_gid st;
set_umask st;
create_home st;
go_home st;
@@ -769,19 +806,23 @@
let kill_mldonkey_server st signal signal_name=
- let pid_server = read_pidfile st
- in
- debug st ("Sending signal "^signal_name^" to process PID ( "^(string_of_int pid_server)^" )");
- if signal = Sys.sigterm then
- stop_or_die st pid_server
+ if daemon_is_running st then
+ let pid_server = read_pidfile st
+ in
+ debug st ("Sending signal "^signal_name^" to process PID ( "^(string_of_int pid_server)^" )");
+ if signal = Sys.sigterm then
+ stop_or_die st pid_server
+ else
+ begin
+ try
+ Unix.kill pid_server signal
+ with Unix.Unix_error (_, _, _) ->
+ ()
+ end
else
- begin
- try
- Unix.kill pid_server signal
- with Unix.Unix_error (_, _, _) ->
- ()
- end
-
+ debug st ("Daemon is not running")
+;;
+
let stop_mldonkey_server st =
kill_mldonkey_server st Sys.sigterm "SIGTERM"
;;
@@ -829,6 +870,16 @@
prerr_string ("No pidfile, maybe no mldonkey_server are running");
prerr_newline ()
end
+ | Invalid_pidfile ->
+ begin
+ prerr_string ("Invalid pidfile, maybe the pidfile is corrupted");
+ prerr_newline ();
+ end
+ | No_proc_entry str ->
+ begin
+ prerr_string ("Cannot find /proc entry for "^str);
+ prerr_newline ();
+ end
| Unix.Unix_error (error,_,_) ->
begin
prerr_string (error_message error);
Modified: trunk/packages/mldonkey/trunk/debian/xml-man/mldonkey_server.xml
===================================================================
--- trunk/packages/mldonkey/trunk/debian/xml-man/mldonkey_server.xml 2005-06-22 14:36:41 UTC (rev 1408)
+++ trunk/packages/mldonkey/trunk/debian/xml-man/mldonkey_server.xml 2005-06-22 22:18:55 UTC (rev 1409)
@@ -93,12 +93,24 @@
<para>What user to run under. By default user who launch mldonkey_server</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--chgid</option></term>
+ <listitem>
+ <para>What group to run under. By default default group of the user who lauch mldonkey_server</para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>--umask</option></term>
<listitem>
<para>What umask to use. By default user 0022</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--nice</option></term>
+ <listitem>
+ <para>Niceness of the process. Only root can set a lower nice value to process.</para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>--end-duration</option></term>
<listitem>