|
From: <mla...@us...> - 2006-11-13 03:14:36
|
Revision: 131
http://svn.sourceforge.net/g15daemon/?rev=131&view=rev
Author: mlampard
Date: 2006-11-12 19:14:20 -0800 (Sun, 12 Nov 2006)
Log Message:
-----------
fix problem with option ordering. add (hidden) cmdline option to change effective uid.
Modified Paths:
--------------
trunk/g15daemon-wip/g15daemon/main.c
trunk/g15daemon-wip/plugins/g15_plugin_uinput.c
Modified: trunk/g15daemon-wip/g15daemon/main.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/main.c 2006-11-13 02:28:53 UTC (rev 130)
+++ trunk/g15daemon-wip/g15daemon/main.c 2006-11-13 03:14:20 UTC (rev 131)
@@ -220,7 +220,9 @@
int retval;
int i;
struct sigaction new_action, old_action;
-
+ cycle_key = G15_KEY_MR;
+ unsigned char user[256];
+
pthread_t keyboard_thread;
pthread_t lcd_thread;
@@ -252,13 +254,19 @@
if (!strncmp(daemonargs, "-s",2) || !strncmp(daemonargs, "--switch",8)) {
cycle_key = G15_KEY_L1;
- }else{
- cycle_key = G15_KEY_MR;
}
if (!strncmp(daemonargs, "-d",2) || !strncmp(daemonargs, "--debug",7)) {
g15daemon_debug = 1;
}
+
+ if (!strncmp(daemonargs, "-u",2) || !strncmp(daemonargs, "--user",7)) {
+ if(argv[i+1]!=NULL){
+ strncpy(user,argv[i+1],128);
+ i++;
+ }
+ }
+
}
if(g15daemon_return_running()>=0) {
g15daemon_log(LOG_ERR,"G15Daemon already running.. Exiting");
@@ -276,8 +284,17 @@
struct passwd *nobody;
unsigned char location[1024];
- openlog("g15daemon", LOG_PID, LOG_DAEMON);
- nobody = getpwnam("nobody");
+ openlog("g15daemon", LOG_PID, LOG_DAEMON);
+ if(strlen(user)==0){
+ nobody = getpwnam("nobody");
+ }else {
+ nobody = getpwnam(user);
+ }
+ if (nobody==NULL)
+ {
+ nobody = getpwuid(geteuid());
+ g15daemon_log(LOG_WARNING,"BEWARE: running as effective uid %i\n",nobody->pw_uid);
+ }
/* init stuff here.. */
retval = initLibG15();
Modified: trunk/g15daemon-wip/plugins/g15_plugin_uinput.c
===================================================================
--- trunk/g15daemon-wip/plugins/g15_plugin_uinput.c 2006-11-13 02:28:53 UTC (rev 130)
+++ trunk/g15daemon-wip/plugins/g15_plugin_uinput.c 2006-11-13 03:14:20 UTC (rev 131)
@@ -48,10 +48,10 @@
int g15_init_uinput(void *plugin_args) {
int i=0;
- struct passwd *nobody;
+ lcdlist_t *displaylist = (lcdlist_t*) plugin_args;
struct uinput_user_dev uinp;
static const char *uinput_device_fn[] = { "/dev/uinput", "/dev/input/uinput",0};
- nobody = getpwnam("nobody");
+
seteuid(0);
setegid(0);
while (uinput_device_fn[i] && (uinp_fd = open(uinput_device_fn[i],O_RDWR))<0){
@@ -62,11 +62,10 @@
return -1;
}
/* all other processes/threads should be seteuid nobody */
- if(nobody!=NULL) {
- seteuid(nobody->pw_uid);
- setegid(nobody->pw_gid);
- }
+ seteuid(displaylist->nobody->pw_uid);
+ setegid(displaylist->nobody->pw_gid);
+
memset(&uinp,0,sizeof(uinp));
strncpy(uinp.name, "G15 Extra Keys", UINPUT_MAX_NAME_SIZE);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|