configure: add option to set default user
The default user is root by default, which disables root dropping by default. The user directive or the -u option can still be used to set the user.
This commit is contained in:
parent
3edd3fe5a4
commit
ff31702f74
5 changed files with 20 additions and 10 deletions
|
@ -1028,8 +1028,9 @@ to work well, it relies on @code{chronyd} having been able to determine
|
||||||
accurate statistics for the difference between the real time clock and
|
accurate statistics for the difference between the real time clock and
|
||||||
system clock last time the computer was on.
|
system clock last time the computer was on.
|
||||||
@item -u <user>
|
@item -u <user>
|
||||||
When this option is used, chronyd will drop root privileges to the specified
|
This option sets the name of the user to which will @code{chronyd} switch to
|
||||||
user. So far, it works only on Linux when compiled with capabilities support.
|
drop root privileges if compiled with Linux capabilities support (default
|
||||||
|
@code{@DEFAULT_USER@}).
|
||||||
@item -q
|
@item -q
|
||||||
When run in this mode, @code{chronyd} will set the system clock once
|
When run in this mode, @code{chronyd} will set the system clock once
|
||||||
and exit. It will not detach from the terminal.
|
and exit. It will not detach from the terminal.
|
||||||
|
@ -2958,10 +2959,11 @@ be set to run 0.183ppm faster than it would be without the compensation, etc.
|
||||||
@node user directive
|
@node user directive
|
||||||
@subsection user
|
@subsection user
|
||||||
The @code{user} directive sets the name of the user to which will
|
The @code{user} directive sets the name of the user to which will
|
||||||
@code{chronyd} drop root privileges after the initialisation. So far, it works
|
@code{chronyd} switch on initialisation to drop root privileges.
|
||||||
only on Linux when compiled with capabilities support.
|
So far, it works only on Linux when compiled with capabilities support.
|
||||||
|
Setting the name to root will disable it.
|
||||||
|
|
||||||
By default, root privileges are not dropped.
|
The default value is @code{@DEFAULT_USER@}.
|
||||||
@c }}}
|
@c }}}
|
||||||
@c }}}
|
@c }}}
|
||||||
@c {{{ S:Running chronyc
|
@c {{{ S:Running chronyc
|
||||||
|
|
|
@ -103,8 +103,9 @@ between the real time clock and system clock last time the
|
||||||
computer was on.
|
computer was on.
|
||||||
.TP
|
.TP
|
||||||
\fB\-u\fR \fIuser\fR
|
\fB\-u\fR \fIuser\fR
|
||||||
When this option is used, chronyd will drop root privileges to the specified
|
This option sets the name of the user to which will \fBchronyd\fR switch to
|
||||||
user. So far, it works only on Linux when compiled with capabilities support.
|
drop root privileges if compiled with Linux capabilities support (default
|
||||||
|
\fB@DEFAULT_USER@\fR).
|
||||||
.TP
|
.TP
|
||||||
.B \-q
|
.B \-q
|
||||||
When run in this mode, chronyd will set the system clock once
|
When run in this mode, chronyd will set the system clock once
|
||||||
|
|
2
conf.c
2
conf.c
|
@ -203,7 +203,7 @@ static int lock_memory = 0;
|
||||||
static char *leapsec_tz = NULL;
|
static char *leapsec_tz = NULL;
|
||||||
|
|
||||||
/* Name of the user to which will be dropped root privileges. */
|
/* Name of the user to which will be dropped root privileges. */
|
||||||
static char *user = NULL;
|
static char *user = DEFAULT_USER;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NTP_Source_Type type;
|
NTP_Source_Type type;
|
||||||
|
|
9
configure
vendored
9
configure
vendored
|
@ -113,6 +113,7 @@ For better control, use the options below.
|
||||||
--disable-rtc Don't include RTC even on Linux
|
--disable-rtc Don't include RTC even on Linux
|
||||||
--disable-linuxcaps Disable Linux capabilities support
|
--disable-linuxcaps Disable Linux capabilities support
|
||||||
--disable-forcednsretry Don't retry on permanent DNS error
|
--disable-forcednsretry Don't retry on permanent DNS error
|
||||||
|
--with-user=USER Specify default chronyd user [root]
|
||||||
--with-sendmail=PATH Path to sendmail binary [/usr/lib/sendmail]
|
--with-sendmail=PATH Path to sendmail binary [/usr/lib/sendmail]
|
||||||
--enable-debug Enable debugging support
|
--enable-debug Enable debugging support
|
||||||
|
|
||||||
|
@ -191,6 +192,7 @@ feat_pps=1
|
||||||
try_setsched=0
|
try_setsched=0
|
||||||
try_lockmem=0
|
try_lockmem=0
|
||||||
feat_forcednsretry=1
|
feat_forcednsretry=1
|
||||||
|
default_user="root"
|
||||||
mail_program="/usr/lib/sendmail"
|
mail_program="/usr/lib/sendmail"
|
||||||
|
|
||||||
for option
|
for option
|
||||||
|
@ -268,6 +270,9 @@ do
|
||||||
--disable-forcednsretry)
|
--disable-forcednsretry)
|
||||||
feat_forcednsretry=0
|
feat_forcednsretry=0
|
||||||
;;
|
;;
|
||||||
|
--with-user=* )
|
||||||
|
default_user=`echo $option | sed -e 's/^.*=//;'`
|
||||||
|
;;
|
||||||
--with-sendmail=* )
|
--with-sendmail=* )
|
||||||
mail_program=`echo $option | sed -e 's/^.*=//;'`
|
mail_program=`echo $option | sed -e 's/^.*=//;'`
|
||||||
;;
|
;;
|
||||||
|
@ -618,6 +623,7 @@ fi
|
||||||
|
|
||||||
add_def DEBUG $debug
|
add_def DEBUG $debug
|
||||||
add_def DEFAULT_CONF_FILE "\"$SYSCONFDIR/chrony.conf\""
|
add_def DEFAULT_CONF_FILE "\"$SYSCONFDIR/chrony.conf\""
|
||||||
|
add_def DEFAULT_USER "\"$default_user\""
|
||||||
add_def MAIL_PROGRAM "\"$mail_program\""
|
add_def MAIL_PROGRAM "\"$mail_program\""
|
||||||
|
|
||||||
if [ -f version.txt ]; then
|
if [ -f version.txt ]; then
|
||||||
|
@ -649,7 +655,8 @@ do
|
||||||
s%@MANDIR@%${MANDIR}%;\
|
s%@MANDIR@%${MANDIR}%;\
|
||||||
s%@INFODIR@%${INFODIR}%;\
|
s%@INFODIR@%${INFODIR}%;\
|
||||||
s%@LOCALSTATEDIR@%${LOCALSTATEDIR}%;\
|
s%@LOCALSTATEDIR@%${LOCALSTATEDIR}%;\
|
||||||
s%@CHRONYVARDIR@%${CHRONYVARDIR}%;"\
|
s%@CHRONYVARDIR@%${CHRONYVARDIR}%;\
|
||||||
|
s%@DEFAULT_USER@%${default_user}%;"\
|
||||||
< ${f}.in > $f
|
< ${f}.in > $f
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
2
main.c
2
main.c
|
@ -466,7 +466,7 @@ int main
|
||||||
if (!user) {
|
if (!user) {
|
||||||
user = CNF_GetUser();
|
user = CNF_GetUser();
|
||||||
}
|
}
|
||||||
if (user) {
|
if (user && strcmp(user, "root")) {
|
||||||
SYS_DropRoot(user);
|
SYS_DropRoot(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue