diff -uwNr -x .cvsignore -x Entries -x Repository -x Root src/daemon/common/commonInteractive.ml src/daemon/common/commonInteractive.ml
--- src/daemon/common/commonInteractive.ml	2011-03-13 18:51:02.000000000 +0100
+++ src/daemon/common/commonInteractive.ml	2011-10-25 21:39:08.000000000 +0200
@@ -263,6 +263,24 @@
 
             if Unix2.is_directory file_name then Unix2.remove_all_directory file_name;
 
+(* if user_chown is set, chown file to Unix user and group of MLDonkey core *)
+	    begin
+	      let user = file_owner file in
+	      if user.user_chown then
+	      try
+		let unix_user = Unix.getpwnam user.user_name in
+		begin
+		  try
+		    Unix.chown new_name unix_user.Unix.pw_uid (Unix.getgid ())
+		  with e ->
+		    lprintf_nl "Exception %s while chmod of %s to user %s"
+		      (Printexc2.to_string e) new_name user.user_name
+		end
+	      with Not_found ->
+                  lprintf_nl "Can not chmod %s to user %s, system user %s does not exist."
+                    new_name user.user_name user.user_name
+	    end;
+
             let impl = as_file_impl file in
 (* When the commit action is called, the file is supposed not to exist anymore. *)
             impl.impl_file_ops.op_file_commit impl.impl_file_val new_name;
diff -uwNr -x .cvsignore -x Entries -x Repository -x Root src/daemon/common/commonTypes.ml src/daemon/common/commonTypes.ml
--- src/daemon/common/commonTypes.ml	2011-01-23 16:20:26.000000000 +0100
+++ src/daemon/common/commonTypes.ml	2011-10-25 21:18:50.000000000 +0200
@@ -539,6 +539,7 @@
   mutable user_default_group : groupdb option;
   mutable user_mail : string;
   mutable user_commit_dir : string;
+  mutable user_chown : bool;
   mutable user_max_concurrent_downloads : int;
 }
 
diff -uwNr -x .cvsignore -x Entries -x Repository -x Root src/daemon/common/commonUserDb.ml src/daemon/common/commonUserDb.ml
--- src/daemon/common/commonUserDb.ml	2007-07-25 21:27:09.000000000 +0200
+++ src/daemon/common/commonUserDb.ml	2011-10-25 21:38:29.000000000 +0200
@@ -146,6 +146,7 @@
   user_default_group = Some (admin_group ());
   user_mail = "";
   user_commit_dir = "";
+  user_chown = false;
   user_max_concurrent_downloads = 0;
   }
 
@@ -176,6 +177,11 @@
               get_value "user_commit_dir" value_to_string
             with _ -> ""
           in
+          let uchown =
+	    try
+              get_value "user_chown" value_to_bool
+            with _ -> false
+          in
           let umaxdl =
 	    try
               get_value "user_max_concurrent_downloads" value_to_int
@@ -223,6 +229,7 @@
 	    user_default_group = udgroup;
 	    user_mail = umail; 
 	    user_commit_dir = ucdir; 
+	    user_chown = uchown; 
 	    user_max_concurrent_downloads = umaxdl; 
 	  }
 
@@ -236,6 +243,7 @@
         "user_default_group", stringoption_to_value (match user.user_default_group with Some g -> Some g.group_name | None -> None);
         "user_mail", string_to_value user.user_mail;
         "user_commit_dir", string_to_value user.user_commit_dir;
+        "user_chown", bool_to_value user.user_chown;
         "user_max_concurrent_downloads", int_to_value user.user_max_concurrent_downloads;
       ]
 
@@ -252,6 +260,7 @@
 user_default_group            = New downloads by this user will belong to this group.
 user_commit_dir               = Commit files to <incoming>/<user_commit_dir>
 user_mail                     = Address used to sent confirmation mails after comitting a download
+user_chown                    = Chown committed file to Unix user <user_name>, if it exists.
 user_max_concurrent_downloads = Maximum number of downloads allowed, 0 = unlimited
 "
     (list_option UserOption.t) [default_admin_user]
@@ -278,7 +287,7 @@
 
 let user2_user_add name pass ?(groups = [admin_group_name])
 			     ?(default_group = Some admin_group_name)
-			     ?(mail = "") ?(commit_dir = "") ?(max_dl = 0) () =
+			     ?(mail = "") ?(commit_dir = "") ?(chown = false) ?(max_dl = 0) () =
   (* shouldn't we warn admin about already existing user ? *)
   let groups = List.map user2_group_find (List.filter user2_group_exists groups) in
   let default_group =
@@ -293,6 +302,7 @@
       user_default_group = default_group;
       user_mail = mail;
       user_commit_dir = commit_dir;
+      user_chown = chown;
       user_max_concurrent_downloads = max_dl;
   } in
   update_user name (Some new_user)
@@ -331,6 +341,14 @@
 let user2_user_set_mail user mail =
   user.user_mail <- mail
 
+let user2_print_user_chown user =
+  try
+    if user.user_chown then "true" else "false"
+  with Not_found -> "false"
+
+let user2_user_set_chown user chown =
+  user.user_chown <- chown
+
 let user2_print_user_dls user =
   let dls = user.user_max_concurrent_downloads in
   if dls = 0 then "unlimited" else string_of_int dls
diff -uwNr -x .cvsignore -x Entries -x Repository -x Root src/daemon/driver/driverCommands.ml src/daemon/driver/driverCommands.ml
--- src/daemon/driver/driverCommands.ml	2011-05-07 20:59:56.000000000 +0200
+++ src/daemon/driver/driverCommands.ml	2011-10-25 21:42:58.000000000 +0200
@@ -3494,6 +3494,22 @@
 	_s ""
     ), "<user> <dir> :\t\tchange user specific commit directory";
 
+    "userchown", Arg_two (fun user chown o ->
+        if user2_is_admin o.conn_user.ui_user
+	  || o.conn_user.ui_user.user_name = user then
+	  begin
+	    try
+	      let u = user2_user_find user in
+	      user2_user_set_chown u (bool_of_string chown);
+	      print_command_result o (Printf.sprintf "Changed user_chown of user %s to %s" u.user_name (user2_print_user_chown u))
+	    with
+	      Not_found -> print_command_result o (Printf.sprintf "User %s does not exist" user)
+	    | Invalid_argument s -> print_command_result o (Printf.sprintf "error %s while parsing command userchown" s)
+	  end
+        else print_command_result o "You are not allowed to change this value";
+	_s ""
+    ), "<user> <true|false> :\t\tshould chown <user> be called on committed files";
+
     "groupadd", Arg_two (fun group admin o ->
 	let g_admin =
 	  try
@@ -3589,6 +3605,7 @@
               ( Str, "srh", "Default group", "Default group" ) ;
               ( Str, "srh", "Mail address", "Email" ) ;
               ( Str, "srh", "Commit dir", "Commit dir" ) ;
+              ( Str, "srh ac", "Chown", "Chown" ) ;
               ( Num, "srh ar", "Download quota", "Max DLs" ) ;
               ( Num, "srh ar", "Download count", "DLs" ) ];
 
@@ -3632,6 +3649,7 @@
 		  ("", "sr", user2_print_user_default_group user);
 		  ("", "sr", user.user_mail);
 		  ("", "sr", user.user_commit_dir);
+		  ("", "sr ac", user2_print_user_chown user);
 		  ("", "sr ar", user2_print_user_dls user);
 		  ("", "sr ar", string_of_int u_dls)];
             );
