You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// forking the process, getting a new sid, setting the umask, changing the standard io streams
27
+
/// forking the process, getting a new Session ID (sid), setting the umask, changing the standard io streams
29
28
/// to files and finally dropping privileges.
30
29
///
31
-
/// Options:
32
-
/// * user [optional], if set will drop privileges to the specified user **NOTE**: This library is strict and makes no assumptions if you provide a user you must provide a group
33
-
/// * group [optional(**see note on user**)], if set will drop privileges to specified group
34
-
/// * umask [optional], umask for the process defaults to 0o027
35
-
/// * pid_file [optional], if set a pid file will be created default is that no file is created *
36
-
/// * stdio [optional][**recommended**], this determines where standard output will be piped to since daemons have no console it's highly recommended to set this
37
-
/// * stderr [optional][**recommended**], same as above but for standard error
38
-
/// * chdir [optional], default is "/"
39
-
/// * name [optional], set the daemon process name eg what shows in `ps` default is to not set a process name
40
-
/// * before_fork_hook [optional], called before the fork with the current pid as argument
41
-
/// * after_fork_parent_hook [optional], called after the fork with the parent pid as argument, can be used to continue some work on the parent after the fork (do not return)
42
-
/// * after_fork_child_hook [optional], called after the fork with the parent and child pid as arguments
43
-
///
44
-
/// * See the setter function documentation for more details
45
-
///
46
-
/// **Beware there is no escalation back if dropping privileges**
30
+
/// **NOTE:** Beware there is no escalation back if dropping privileges
47
31
pubstructDaemon<'a>{
48
32
pub(crate)chdir:PathBuf,
49
33
pub(crate)pid_file:Option<PathBuf>,
@@ -84,7 +68,10 @@ impl<'a> Daemon<'a> {
84
68
}
85
69
}
86
70
87
-
/// This is a setter to give your daemon a pid file
71
+
/// Give your daemon a pid file
72
+
///
73
+
/// By default, no pid file is created.
74
+
///
88
75
/// # Arguments
89
76
/// * `path` - path to the file suggested `/var/run/my_program_name.pid`
90
77
/// * `chmod` - if set a chmod of the file to the user and group passed will be attempted (**this being true makes setting an user and group mandatory**)
@@ -101,12 +88,16 @@ impl<'a> Daemon<'a> {
101
88
}
102
89
103
90
/// The code will attempt to drop privileges with `setuid` to the provided user
91
+
///
92
+
/// **NOTE:** If you provide a user, you must also provide a group.
104
93
pubfnuser<T:Into<User>>(mutself,user:T) -> Self{
105
94
self.user = Some(user.into());
106
95
self
107
96
}
108
97
109
-
/// The code will attempt to drop privileges with `setgid` to the provided group, you mut provide a group if you provide an user
98
+
/// The code will attempt to drop privileges with `setgid` to the provided group
99
+
///
100
+
/// **NOTE:** You must provide a group if you provide an user.
0 commit comments