pkg://Canna-3.5b2-50.src.rpm:2637951/Canna35b2-user.patch
info downloads
--- Canna35b2/server/misc.c.user Tue Aug 7 13:29:00 2001
+++ Canna35b2/server/misc.c Tue Aug 7 13:34:06 2001
@@ -46,11 +46,12 @@
#include <fcntl.h>
#endif
#ifdef __EMX__
-#include <sys/types.h>
#include <unistd.h>
#endif
#include <signal.h>
+#include <pwd.h>
#include <sys/ioctl.h>
+#include <sys/types.h>
#include "IR.h"
#include "net.h"
@@ -87,6 +88,8 @@
int MMountFlag = 0; /* メモリに辞書をロードするかしないかのフラグ */
static char Name[64];
+static char *userID=NULL; /* canna server's user id */
+
#define MAX_PREMOUNTS 20
char *PreMountTabl[MAX_PREMOUNTS];
@@ -99,7 +102,7 @@
static void Reset();
static void parQUIT();
-#define USAGE "Usage: cannaserver [-p num] [-l num] [-d] [-syslog] [dichome]"
+#define USAGE "Usage: cannaserver [-p num] [-l num] [-d] [-u userid] [-syslog] [dichome]"
static void
Usage()
{
@@ -117,6 +120,7 @@
char buf[ MAXDATA ];
int parent, parentid, i;
int context;
+ struct passwd *pwent;
strcpy( Name, argv[ 0 ] );
@@ -142,6 +146,16 @@
MMountFlag = RK_MMOUNT;
}
#endif
+ else if( !strcmp( argv[i], "-u")) {
+ if (++i < argc) {
+ userID = argv[i];
+ }
+ else {
+ fprintf(stderr, "%s\n", USAGE);
+ exit(2);
+ /* NOTREACHED */
+ }
+ }
#ifndef __EMX__
else if (!strcmp( argv[i], "-syslog")) {
Syslog = 1;
@@ -168,6 +182,23 @@
strcpy( (char *)ddname, DICHOME );
}
+ if (userID != NULL) {
+ pwent = getpwnam(userID);
+ if (pwent) {
+ if(setgid(pwent->pw_gid)) {
+ FatalError("cannaserver:couldn't set groupid to canna user's group\n");
+ }
+ if (initgroups(userID, pwent->pw_gid)) {
+ FatalError("cannserver: couldn't init supplementary groups\n");
+ }
+ if (setuid(pwent->pw_uid)) {
+ FatalError("cannaserver: couldn't set userid to %s user\n", userID);
+ }
+ } else if (userID != NULL) {
+ FatalError("cannaserver: -u flag specified, but canna not run as root\n");
+ }
+ }
+
#ifdef DEBUG
DebugMode = 0 ;
ServerLogFp = stderr ;
--- Canna35b2/server/Imakefile.user Tue Aug 21 11:36:56 2001
+++ Canna35b2/server/Imakefile Tue Aug 21 11:38:05 2001
@@ -2,7 +2,7 @@
#include "../Canna.conf"
CANNAROOT = ..
- INSTUGIDFLAGS = -m 6555
+ INSTUGIDFLAGS = -m 555
#ifdef __EMX__
INSTFLAGS = $(INSTUGIDFLAGS)
LOCAL_LIBRARIES = $(CANNAROOT)/lib/RK/RK.a