=== modified file 'bitlbee.conf'
old
|
new
|
|
19 | 19 | ## |
20 | 20 | # RunMode = Inetd |
21 | 21 | |
| 22 | ## User: |
| 23 | ## |
| 24 | ## If BitlBee is run as root as a Daemon or ForkDaemon, it can drop root |
| 25 | ## privileges, and change to specified user. |
| 26 | ## |
| 27 | # User = bitlbee |
| 28 | |
22 | 29 | ## DaemonPort/DaemonInterface: |
23 | 30 | ## |
24 | 31 | ## For daemon mode, you can specify on what interface and port the daemon |
=== modified file 'conf.c'
old
|
new
|
|
66 | 66 | conf->motdfile = g_strdup( ETCDIR "/motd.txt" ); |
67 | 67 | conf->ping_interval = 180; |
68 | 68 | conf->ping_timeout = 300; |
| 69 | conf->user = ""; |
69 | 70 | proxytype = 0; |
70 | 71 | |
71 | 72 | i = conf_loadini( conf, CONF_FILE ); |
… |
… |
|
79 | 80 | fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", CONF_FILE ); |
80 | 81 | } |
81 | 82 | |
82 | | while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:" ) ) >= 0 ) |
| 83 | while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 ) |
83 | 84 | /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ |
84 | 85 | { |
85 | 86 | if( opt == 'i' ) |
… |
… |
|
139 | 140 | " -I Classic/InetD mode. (Default)\n" |
140 | 141 | " -D Daemon mode. (Still EXPERIMENTAL!)\n" |
141 | 142 | " -F Forking daemon. (one process per client)\n" |
| 143 | " -u Run daemon as specified user.\n" |
142 | 144 | " -P Specify PID-file (not for inetd mode)\n" |
143 | 145 | " -i Specify the interface (by IP address) to listen on.\n" |
144 | 146 | " (Default: 0.0.0.0 (any interface))\n" |
… |
… |
|
158 | 160 | mode anyway!) */ |
159 | 161 | ipc_master_set_statefile( optarg ); |
160 | 162 | } |
| 163 | else if(opt == 'u' ) |
| 164 | { |
| 165 | conf->user = g_strdup( optarg ); |
| 166 | } |
161 | 167 | } |
162 | 168 | |
163 | 169 | if( conf->configdir[strlen(conf->configdir)-1] != '/' ) |
… |
… |
|
293 | 299 | |
294 | 300 | g_free( url ); |
295 | 301 | } |
| 302 | else if( g_strcasecmp( ini->key, "user" ) == 0 ) |
| 303 | { |
| 304 | conf->user = g_strdup( ini->value ); |
| 305 | } |
296 | 306 | else |
297 | 307 | { |
298 | 308 | fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key ); |
=== modified file 'conf.h'
old
|
new
|
|
48 | 48 | char **migrate_storage; |
49 | 49 | int ping_interval; |
50 | 50 | int ping_timeout; |
| 51 | char *user; |
51 | 52 | } conf_t; |
52 | 53 | |
53 | 54 | conf_t *conf_load( int argc, char *argv[] ); |
=== modified file 'unix.c'
old
|
new
|
|
33 | 33 | #include <unistd.h> |
34 | 34 | #include <sys/time.h> |
35 | 35 | #include <sys/wait.h> |
| 36 | #include <pwd.h> |
36 | 37 | |
37 | 38 | global_t global; /* Against global namespace pollution */ |
38 | 39 | |
… |
… |
|
59 | 60 | if( global.conf == NULL ) |
60 | 61 | return( 1 ); |
61 | 62 | |
| 63 | if( ( global.conf->runmode == RUNMODE_DAEMON || |
| 64 | global.conf->runmode == RUNMODE_FORKDAEMON ) |
| 65 | && ( !getuid() || !geteuid() ) ) |
| 66 | { |
| 67 | struct passwd *pw = NULL; |
| 68 | pw = getpwnam(global.conf->user); |
| 69 | if (pw) |
| 70 | { |
| 71 | setgid(pw->pw_gid); |
| 72 | setuid(pw->pw_uid); |
| 73 | } |
| 74 | } |
| 75 | |
62 | 76 | if( global.conf->runmode == RUNMODE_INETD ) |
63 | 77 | { |
64 | 78 | i = bitlbee_inetd_init(); |