[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [2973] Possibility to define a different gid/uid for s
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [2973] Possibility to define a different gid/uid for spawned processes. |
Date: |
Sat, 29 Nov 2008 18:19:51 +0000 |
Revision: 2973
http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2973
Author: gscrivano
Date: 2008-11-29 18:19:49 +0000 (Sat, 29 Nov 2008)
Log Message:
-----------
Possibility to define a different gid/uid for spawned processes.
Modified Paths:
--------------
trunk/myserver/include/base/process/process.h
trunk/myserver/src/base/process/fork_server.cpp
trunk/myserver/src/base/process/process.cpp
Modified: trunk/myserver/include/base/process/process.h
===================================================================
--- trunk/myserver/include/base/process/process.h 2008-11-23 22:05:20 UTC
(rev 2972)
+++ trunk/myserver/include/base/process/process.h 2008-11-29 18:19:49 UTC
(rev 2973)
@@ -48,8 +48,20 @@
/*! added for unix support. */
string cmd;
string arg;
-
+
+ /*! Group id for the new process. */
+ int gid;
+
+ /*! User id for the new process. */
+ int uid;
+
void *envString;
+
+ StartProcInfo ()
+ {
+ gid = uid = 0;
+ envString = NULL;
+ }
};
class Process
Modified: trunk/myserver/src/base/process/fork_server.cpp
===================================================================
--- trunk/myserver/src/base/process/fork_server.cpp 2008-11-23 22:05:20 UTC
(rev 2972)
+++ trunk/myserver/src/base/process/fork_server.cpp 2008-11-29 18:19:49 UTC
(rev 2973)
@@ -124,7 +124,7 @@
int ForkServer::handleRequest (Socket sin, Socket sout, Socket *serverSock)
{
#ifdef NOT_WIN
- int ret, flags, stdIn, stdOut, stdErr;
+ int ret, flags, stdIn, stdOut, stdErr, gid, uid;
char *exec;
char *cwd;
char *arg;
@@ -133,7 +133,9 @@
if (readInt (&sin, &flags) ||
readInt (&sin, &stdIn) ||
readInt (&sin, &stdOut) ||
- readInt (&sin, &stdErr))
+ readInt (&sin, &stdErr) ||
+ readInt (&sin, &gid) ||
+ readInt (&sin, &uid))
{
return -1;
}
@@ -236,6 +238,12 @@
/* Close the fork server descriptor in the child process. */
serverSock->close ();
+
+ if (gid)
+ Process::setgid (gid);
+
+ if (uid)
+ Process::setuid (uid);
if (Process::generateArgList (args, spi.cmd.c_str (), spi.arg))
exit (1);
@@ -421,6 +429,9 @@
writeInt (sin, spi->stdOut);
writeInt (sin, spi->stdError);
+ writeInt (sin, spi->gid);
+ writeInt (sin, spi->uid);
+
writeString (sin, spi->cmd.c_str (), spi->cmd.length () + 1);
writeString (sin, spi->cwd.c_str (), spi->cwd.length () + 1);
writeString (sin, spi->arg.c_str (), spi->arg.length () + 1);
Modified: trunk/myserver/src/base/process/process.cpp
===================================================================
--- trunk/myserver/src/base/process/process.cpp 2008-11-23 22:05:20 UTC (rev
2972)
+++ trunk/myserver/src/base/process/process.cpp 2008-11-29 18:19:49 UTC (rev
2973)
@@ -212,7 +212,14 @@
// Set env vars
const char *envp[100];
const char *args[100];
+
+ if (spi->gid)
+ Process::setgid (spi->gid);
+
+ if (spi->uid)
+ Process::setuid (spi->uid);
+
if (generateArgList (args, spi->cmd.c_str (), spi->arg))
exit (1);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [2973] Possibility to define a different gid/uid for spawned processes.,
Giuseppe Scrivano <=