コード例 #1
0
ファイル: sfedit.c プロジェクト: LightSys/centrallix
/*** sfeLoadFile - loads a new file into the program.
 ***/
int
sfeLoadFile(char* filename)
    {
    pFile fd;
    pStructInf new_filedata;

	/** open the file. **/
	if (strlen(filename) > 255) return -1;
	fd = fdOpen(filename, O_RDONLY, 0600);
	if (!fd) return -1;

	/** Try to parse it **/
	new_filedata = stParseMsg(fd, 0);
	fdClose(fd,0);
	if (!new_filedata) return -1;
	if (SFE_Globals.Data) stFreeInf(SFE_Globals.Data);
	SFE_Globals.Data = new_filedata;
	SFE_Globals.Modified = 0;

	/** Set the filename and title **/
	strcpy(SFE_Globals.Filename, filename);
	sfeSetTitle(GTK_WINDOW(SFE_Globals.Window), SFE_Globals.Filename);

	/** Rebuild the ui **/
	sfeRebuildUI(SFE_Globals.Data, GTK_TREE(SFE_Globals.TreeView));

    return 0;
    }
コード例 #2
0
ファイル: rpmio.c プロジェクト: akozumpl/rpm
FD_t Fopen(const char *path, const char *fmode)
{
    char stdio[20], other[20];
    const char *end = NULL;
    mode_t perms = 0666;
    int flags = 0;
    FD_t fd;

    if (path == NULL || fmode == NULL)
	return NULL;

    stdio[0] = '\0';
    cvtfmode(fmode, stdio, sizeof(stdio), other, sizeof(other), &end, &flags);
    if (stdio[0] == '\0')
	return NULL;

    if (end == NULL || rstreq(end, "fdio")) {
if (_rpmio_debug)
fprintf(stderr, "*** Fopen fdio path %s fmode %s\n", path, fmode);
	fd = fdOpen(path, flags, perms);
	if (fdFileno(fd) < 0) {
	    if (fd) (void) fdClose(fd);
	    return NULL;
	}
    } else {
	/* XXX gzdio and bzdio here too */

	switch (urlIsURL(path)) {
	case URL_IS_HTTPS:
	case URL_IS_HTTP:
	case URL_IS_HKP:
	case URL_IS_PATH:
	case URL_IS_DASH:
	case URL_IS_FTP:
	case URL_IS_UNKNOWN:
if (_rpmio_debug)
fprintf(stderr, "*** Fopen ufdio path %s fmode %s\n", path, fmode);
	    fd = ufdOpen(path, flags, perms);
	    if (fd == NULL || !(fdFileno(fd) >= 0))
		return fd;
	    break;
	default:
if (_rpmio_debug)
fprintf(stderr, "*** Fopen WTFO path %s fmode %s\n", path, fmode);
	    return NULL;
	    break;
	}

    }

    if (fd)
	fd = Fdopen(fd, fmode);

    DBGIO(fd, (stderr, "==>\tFopen(\"%s\",%x,0%o) %s\n",
	  path, (unsigned)flags, (unsigned)perms, fdbg(fd)));

    return fd;
}
コード例 #3
0
ファイル: AGpio.cpp プロジェクト: my12doom/pilot2
 AGPIO::AGPIO(const char*fdPath,int ioID)
 {
     openStatus = 0;
     fdGpio = 0;
     if(fdOpen(fdPath) < 0)
     {
         LOG2("androidUAV:Error occur\n");
     }
     setIoID(ioID);
 }
コード例 #4
0
ファイル: test_mtlexer_20.c プロジェクト: LightSys/centrallix
long long
test(char** tname)
    {
    int i;
    int j;
    int t;
    int n;
    int iter;
    pLxSession lxs;
    pFile fd;
    char buf[256];

	*tname = "mtlexer-20 NODISCARD flag test";

	mssInitialize("system", "", "", 0, "test");

	iter = 60000;

	for(i=0;i<iter;i++)
	    {
	    fd = fdOpen("tests/test_mtlexer_20.txt", O_RDONLY, 0600);
	    assert(fd != NULL);
	    lxs = mlxOpenSession(fd, MLX_F_EOL | MLX_F_EOF | MLX_F_NODISCARD);
	    assert(lxs != NULL);
	    for(j=1;j<=3;j++)
		{
		t = mlxNextToken(lxs);
		assert(t == MLX_TOK_KEYWORD);
		t = mlxNextToken(lxs);
		assert(t == MLX_TOK_COLON);
		t = mlxNextToken(lxs);
		assert(t == MLX_TOK_KEYWORD);
		t = mlxNextToken(lxs);
		assert(t == MLX_TOK_EOL);
		}
	    t = mlxNextToken(lxs);
	    assert(t == MLX_TOK_EOL);
	    mlxCloseSession(lxs);
	    n = fdRead(fd, buf, sizeof(buf) - 1, 0, 0);
	    assert(n >= 0);
	    buf[n] = '\0';
	    assert(strcmp(buf, "This is some text.\n") == 0);
	    fdClose(fd, 0);
	    }

    return iter;
    }
コード例 #5
0
ファイル: rpmio.c プロジェクト: akozumpl/rpm
static FD_t ufdOpen(const char * url, int flags, mode_t mode)
{
    FD_t fd = NULL;
    const char * path;
    urltype urlType = urlPath(url, &path);

if (_rpmio_debug)
fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o)\n", url, (unsigned)flags, (unsigned)mode);

    switch (urlType) {
    case URL_IS_FTP:
    case URL_IS_HTTPS:
    case URL_IS_HTTP:
    case URL_IS_HKP:
	fd = urlOpen(url, flags, mode);
	/* we're dealing with local file when urlOpen() returns */
	urlType = URL_IS_UNKNOWN;
	break;
    case URL_IS_DASH:
	if ((flags & O_ACCMODE) == O_RDWR) {
	    fd = NULL;
	} else {
	    fd = fdDup((flags & O_ACCMODE) == O_WRONLY ?
			STDOUT_FILENO : STDIN_FILENO);
	}
	break;
    case URL_IS_PATH:
    case URL_IS_UNKNOWN:
    default:
	fd = fdOpen(path, flags, mode);
	break;
    }

    if (fd == NULL) return NULL;

    fdSetIo(fd, ufdio);
    fd->urlType = urlType;

    if (Fileno(fd) < 0) {
	(void) fdClose(fd);
	return NULL;
    }
    return fd;
}
コード例 #6
0
ファイル: rpm.c プロジェクト: BackupTheBerlios/geoirc
/* Get the size of the file */
static size_t RPMSize(install_info *info, const char *path)
{
    FD_t fdi;
    Header hd;
	size_t size = 0;
    int_32 type, c;
    void *p;
	int rc;

    fdi = fdOpen(path, O_RDONLY, 0644);
    rc = rpmReadPackageHeader(fdi, &hd, NULL, NULL, NULL);
    if ( rc ) {
		log_warning(_("RPM error: %s"), rpmErrorString());
        fdClose(fdi);
        return 0;
    }

	headerGetEntry(hd, RPMTAG_SIZE, &type, &p, &c);
	if(type==RPM_INT32_TYPE){
		size = *(int_32*) p;
	}
 	fdClose(fdi);
	return size;
}
コード例 #7
0
ファイル: rpmio.c プロジェクト: maxamillion/rpm
static FD_t urlOpen(const char * url, int flags, mode_t mode)
{
    FD_t fd;
    char *dest = NULL;
    int rc = 1; /* assume failure */

    fd = rpmMkTempFile(NULL, &dest);
    if (fd == NULL) {
	return NULL;
    }
    Fclose(fd);

    rc = urlGetFile(url, dest);
    if (rc == 0) {
	fd = fdOpen(dest, flags, mode);
	unlink(dest);
    } else {
	fd = NULL;
    }
    dest = _free(dest);

    return fd;

}
コード例 #8
0
ファイル: rpm.c プロジェクト: BackupTheBerlios/geoirc
/* Extract the file */
static size_t RPMCopy(install_info *info, const char *path, const char *dest, const char *current_option_name, 
		      xmlNodePtr node,
		      int (*update)(install_info *info, const char *path, size_t progress, size_t size, const char *current))
{
    FD_t fdi;
    Header hd;
    size_t size;
    int_32 type, c;
    int rc, isSource;
    void *p;
	const char *reloc = xmlGetProp(node, "relocate");
	const char *autorm = xmlGetProp(node, "autoremove");
	const char *depsoff = xmlGetProp(node, "nodeps");
	int relocate = (reloc && !strcasecmp(reloc, "true"));
	int autoremove = (autorm && !strcasecmp(autorm, "true"));
	int nodeps = (depsoff && !strcasecmp(depsoff, "true"));

    fdi = fdOpen(path, O_RDONLY, 0644);
    rc = rpmReadPackageHeader(fdi, &hd, &isSource, NULL, NULL);
    if ( rc ) {
		log_warning(_("RPM error: %s"), rpmErrorString());
        return 0;
    }

    size = 0;
    if ( rpm_access && ! force_manual ) { /* We can call RPM directly */
        char cmd[300];
        FILE *fp;
        float percent = 0.0;
		double bytes_copied = 0.0;
		double previous_bytes = 0.0;
        char *name = "", *version = "", *release = "";
		char *options = (char *) malloc(PATH_MAX);
		options[0] = '\0';

        headerGetEntry(hd, RPMTAG_SIZE, &type, &p, &c);
        if(type==RPM_INT32_TYPE){
			size = *(int_32*) p;
        }
        headerGetEntry(hd, RPMTAG_RELEASE, &type, &p, &c);
        if(type==RPM_STRING_TYPE){
			release = (char *) p;
        }
        headerGetEntry(hd, RPMTAG_NAME, &type, &p, &c);
        if(type==RPM_STRING_TYPE){
			name = (char*)p;
        }
        headerGetEntry(hd, RPMTAG_VERSION, &type, &p, &c);
        if(type==RPM_STRING_TYPE){
			version = (char*)p;
        }
        fdClose(fdi);

		if (relocate) { /* force relocating RPM to install directory */
			sprintf(options, " --relocate /=%s --badreloc ", dest);
		}

		if (nodeps) {
			strcat(options, " --nodeps ");
		}

		snprintf(cmd,sizeof(cmd),"rpm -U --percent --root %s %s %s", rpm_root,
				 options, path);

		fp = popen(cmd, "r");
		while ( percent < 100.0 ) {
			if(!fp || feof(fp)){
				pclose(fp);
				free(options);
				log_warning(_("Unable to install RPM file: '%s'"), path);
				return 0;
			}
			fscanf(fp,"%s", cmd);
			if(strcmp(cmd,"%%")){
				pclose(fp);
				free(options);
				log_warning(_("Unable to install RPM file: '%s'"), path);
				return 0;
			}
			fscanf(fp,"%f", &percent);
			/* calculate the bytes installed in this pass of the loop */
			bytes_copied = (percent/100.0)*size - previous_bytes;
			previous_bytes += bytes_copied;
			info->installed_bytes += bytes_copied;
			if ( ! update(info, path, (percent/100.0)*size, size, current_option_name) )
				break;
		}
		pclose(fp);
		free (options);
		/* Log the RPM installation */
		add_rpm_entry(info, current_option, name, version, atoi(release), autoremove);
    } else { /* Manually install the RPM file */
        gzFile gzdi = NULL;
		BZFILE *bzdi = NULL;
		FILE *fd = NULL;
		unsigned char magic[2];
        stream *cpio;
    
        if(headerIsEntry(hd, RPMTAG_PREIN)){      
			headerGetEntry(hd, RPMTAG_PREIN, &type, &p, &c);
			if(type==RPM_STRING_TYPE)
				run_script(info, (char*)p, 1, 1);
        }

		/* Identify the type of compression for the archive */
		if ( fdRead(fdi, magic, 2) < 2 ) {
			return 0;
		}
		lseek(fdFileno(fdi), -2L, SEEK_CUR); 
		if ( magic[0]==037 && magic[1]==0213 ) {
			gzdi = gzdopen(fdFileno(fdi), "r");    /* XXX gzdi == fdi */
		} else if ( magic[0]=='B' && magic[1]=='Z' ) {
			bzdi = BZDOPEN(fdFileno(fdi), "r");
		} else { /* Assume not compressed */
			fd = fdopen(fdFileno(fdi), "r");
		}
		
        cpio = file_fdopen(info, path, fd, gzdi, bzdi, "r");

        /* if relocate="true", copy the files into dest instead of rpm_root */
		if (relocate) {
			size = copy_cpio_stream(info, cpio, dest, current_option_name, node, update);
		} else {
			size = copy_cpio_stream(info, cpio, rpm_root, current_option_name, node, update);
		}

        if(headerIsEntry(hd, RPMTAG_POSTIN)){      
			headerGetEntry(hd, RPMTAG_POSTIN, &type, &p, &c);
			if(type==RPM_STRING_TYPE)
				run_script(info, (char*)p, 1, 1);
        }

        /* Append the uninstall scripts to the uninstall */
        if(headerIsEntry(hd, RPMTAG_PREUN)){      
			headerGetEntry(hd, RPMTAG_PREUN, &type, &p, &c);
			if(type==RPM_STRING_TYPE)
				add_script_entry(info, current_option, (char*)p, 0);
        }
        if(headerIsEntry(hd, RPMTAG_POSTUN)){      
			headerGetEntry(hd, RPMTAG_POSTUN, &type, &p, &c);
			if(type==RPM_STRING_TYPE)
				add_script_entry(info, current_option, (char*)p, 1);
        }
        fdClose(fdi);
    }
    return size;
}
コード例 #9
0
ファイル: objdrv_uxprint.c プロジェクト: LightSys/centrallix
/*** uxpWrite - write to a new print job.  Each time this driver is opened
 *** and written to, it spools a new print job.
 ***/
int
uxpWrite(void* inf_v, char* buffer, int cnt, int offset, int flags, pObjTrxTree* oxt)
    {
    pUxpData inf = UXP(inf_v);
    int rval;
    char* spooldir = NULL;
    char* type = NULL;
    struct stat fileinfo;
    int start_filter = 0;
    int saved_errno;

	/** Start the filter process? **/
	if (!inf->SpoolFileFD && !inf->MasterFD)
	    {
	    start_filter = 1;
	    }

    	/** Ok, need to create a new print job? **/
	if (inf->SpoolFileFD == NULL)
	    {
	    /** Get spool dir. **/
	    stAttrValue(stLookup(inf->Node->Data,"spool_directory"), NULL, &spooldir, 0);
	    if (!spooldir) 
	        {
		mssError(1,"UXP","Spool directory not specified in node object");
		return -1;
		}

	    /** Generate a spool file name **/
	  TRY_SPOOL_AGAIN:
	    do  {
	        sprintf(inf->SpoolPathname,"%s/%8.8d.job",spooldir,UXP_INF.SpoolCnt++);
		} while (lstat(inf->SpoolPathname, &fileinfo) == 0);

	    /** Open the spool file **/
	    inf->SpoolFileFD = fdOpen(inf->SpoolPathname, O_WRONLY | O_CREAT | O_EXCL, 0600);
	    if (!inf->SpoolFileFD) 
	        {
		/** oops - race condition, someone else got it, try again **/
		saved_errno = errno;
		if (lstat(inf->SpoolPathname, &fileinfo) == 0) goto TRY_SPOOL_AGAIN;

		/** Oh well, can't open the thing. **/
		/** Shouldn't be writing to errno, but mssErrorErrno wants it... sigh... **/
		errno = saved_errno;
		mssErrorErrno(1,"UXP","Could not open spool file");
		return -1;
		}
	    }

	/** Ok, delayed start of filter process to wait until spoofile-fd is open **/
	if (start_filter)
	    {
	    stAttrValue(stLookup(inf->Node->Data,"type"), NULL, &type, 0);
	    if (type && strcmp(type, inf->ReqType) && !strcmp(inf->ReqType,"text/html"))
	        {
		uxp_internal_StartFilter(inf);
		}
	    }

	/** Need to filter the data? **/
	if (inf->MasterFD)
	    {
	    rval = fdWrite(inf->MasterFD, buffer, cnt, offset, flags);
	    }
	else
	    {
	    /** Write to the spool file. **/
	    rval = fdWrite(inf->SpoolFileFD, buffer, cnt, offset, flags);
	    }

    return rval;
    }
コード例 #10
0
ファイル: cxpasswd.c プロジェクト: LightSys/centrallix
void
start(void* v)
    {
    char enc_pass[64];
    char salt[MSS_SALT_SIZE + 1];
    char passwd_line[128];
    XString passwd_contents;
    pFile passwd_file;
    char buf[256];
    int len;
    int offset;
    int pos;
    int uname_len;
    int found_user;
    size_t found_len;
    char* nlptr;
    char* ptr;

	cxssInitialize();

	/** No file specified? **/
	if (!CXPASSWD.PasswdFile[0]) 
	    {
	    puts("no passwd file specified (use option -f).");
	    exit(1);
	    }
	
	/** User asked us to read password from stdin? **/
	if (CXPASSWD.ReadStdin)
	    {
	    fgets(CXPASSWD.Password, sizeof(CXPASSWD.Password), stdin);
	    if (strchr(CXPASSWD.Password, '\n'))
		{
		*strchr(CXPASSWD.Password, '\n') = '\0';
		}
	    }

	/** Now get username and/or password if not supplied on command line **/
	if (!CXPASSWD.UserName[0]) 
	    {
	    ptr = readline("Username: "******"Password: "******"could not generate random bytes for password salt.");
	    exit(1);
	    }

	/** Generate encrypted credential **/
	if (mssGenCred(salt, MSS_SALT_SIZE, CXPASSWD.Password, enc_pass, sizeof(enc_pass)) < 0)
	    {
	    puts("could not generate encrypted password.");
	    exit(1);
	    }

	/** Generate our password file line **/
	snprintf(passwd_line, sizeof(passwd_line), "%s:%s\n", CXPASSWD.UserName, enc_pass);

	/** Open the password file **/
	passwd_file = fdOpen(CXPASSWD.PasswdFile, O_RDWR | O_CREAT, 0600);
	if (!passwd_file)
	    {
	    puts("could not open passwd file.");
	    exit(1);
	    }

	/** Read it into the xstring **/
	xsInit(&passwd_contents);
	while((len = fdRead(passwd_file, buf, sizeof(buf), 0, 0)) > 0)
	    {
	    xsConcatenate(&passwd_contents, buf, len);
	    }
	fdClose(passwd_file, 0);
	
	/** Do we already have this user? **/
	uname_len = strlen(CXPASSWD.UserName);
	offset = 0;
	found_user = -1;
	while((pos = xsFind(&passwd_contents, CXPASSWD.UserName, uname_len, offset)) >= 0)
	    {
	    if ((pos == 0 || xsString(&passwd_contents)[pos-1] == '\n') && xsString(&passwd_contents)[pos+uname_len] == ':')
		{
		/** Found it **/
		found_user = pos;
		found_len = strlen(xsString(&passwd_contents)+pos);
		if ((nlptr = strchr(xsString(&passwd_contents)+pos, '\n')) != NULL)
		    found_len = (nlptr - (xsString(&passwd_contents)+pos)) + 1;
		break;
		}
	    offset = pos+1;
	    }

	/** Replace if found, otherwise add the new user **/
	if (found_user >= 0)
	    xsSubst(&passwd_contents, found_user, found_len, passwd_line, strlen(passwd_line));
	else
	    xsConcatenate(&passwd_contents, passwd_line, strlen(passwd_line));

	/** Rewrite the entire file **/
	passwd_file = fdOpen(CXPASSWD.PasswdFile, O_RDWR | O_CREAT | O_TRUNC, 0600);
	if (!passwd_file)
	    {
	    puts("could not open password file to write to it.");
	    exit(1);
	    }

	if (fdWrite(passwd_file, xsString(&passwd_contents), strlen(xsString(&passwd_contents)), 0, FD_U_SEEK | FD_U_PACKET) != strlen(xsString(&passwd_contents)))
	    {
	    puts("could not re-write new password file.");
	    exit(1);
	    }

	/** Close the file **/
	fdClose(passwd_file, 0);

    exit(0);
    }
コード例 #11
0
ファイル: mtsession.c プロジェクト: LightSys/centrallix
/*** mssAuthenticate - start a new session, overwriting previous
 *** (inherited) session information.
 ***/
int 
mssAuthenticate(char* username, char* password)
    {
    pMtSession s;
    char* encrypted_pwd;
    char* pwd;
    struct passwd* pw = NULL;
#ifdef HAVE_SHADOW_H
    struct spwd* spw;
#endif
    char salt[3];
    pFile altpass_fd;
    pLxSession altpass_lxs;
    char pwline[80];
    int t;
    int found_user;
    gid_t grps[16];
    int n_grps;

	/** Allocate a new session structure. **/
	s = (pMtSession)nmMalloc(sizeof(MtSession));
	if (!s) return -1;
	s->LinkCnt = 1;
	strncpy(s->UserName, username, 31);
	s->UserName[31]=0;
	strncpy(s->Password, password, 31);
	s->Password[31]=0;

	/** Attempt to authenticate. **/
	if (!strcmp(MSS.AuthMethod,"system"))
	    {
	    /** Use system auth (passwd/shadow files) **/
	    pw = getpwnam(s->UserName);
	    if (!pw)
		{
		memset(s, 0, sizeof(MtSession));
		nmFree(s,sizeof(MtSession));
		return -1;
		}
#ifdef HAVE_SHADOW_H
	    spw = getspnam(s->UserName);
	    if (!spw)
		{
#endif
		pwd = pw->pw_passwd;
#ifdef HAVE_SHADOW_H
		}
	    else
		{
		pwd = spw->sp_pwdp;
		}
#endif
	    strncpy(salt,pwd,2);
	    salt[2]=0;
	    encrypted_pwd = (char*)crypt(s->Password,pwd);
	    if (strcmp(encrypted_pwd,pwd))
		{
		memset(s, 0, sizeof(MtSession));
		nmFree(s,sizeof(MtSession));
		return -1;
		}
	    }
	else if (!strcmp(MSS.AuthMethod, "altpasswd"))
	    {
	    /** Sanity checking. **/
	    if (strchr(username,':'))
		{
		mssError(1, "MSS", "Attempt to use invalid username '%s'", username);
		memset(s, 0, sizeof(MtSession));
		nmFree(s,sizeof(MtSession));
		return -1;
		}

	    /** Open the alternate password file **/
	    altpass_fd = fdOpen(MSS.AuthFile, O_RDONLY, 0600);
	    if (!altpass_fd)
		{
		mssErrorErrno(1, "MSS", "Could not open auth file '%s'", MSS.AuthFile);
		memset(s, 0, sizeof(MtSession));
		nmFree(s,sizeof(MtSession));
		return -1;
		}
	    altpass_lxs = mlxOpenSession(altpass_fd, MLX_F_LINEONLY | MLX_F_EOF);

	    /** Scan it for the user name **/
	    found_user = 0;
	    while ((t = mlxNextToken(altpass_lxs)) != MLX_TOK_EOF)
		{
		if (t == MLX_TOK_ERROR)
		    {
		    mssError(0, "MSS", "Could not read auth file '%s'", MSS.AuthFile);
		    memset(s, 0, sizeof(MtSession));
		    nmFree(s,sizeof(MtSession));
		    mlxCloseSession(altpass_lxs);
		    fdClose(altpass_fd, 0);
		    return -1;
		    }
		mlxCopyToken(altpass_lxs, pwline, 80);
		if (strlen(username) < strlen(pwline) && !strncmp(pwline, username, strlen(username)) && pwline[strlen(username)] == ':')
		    {
		    found_user = 1;
		    break;
		    }
		}

	    /** Close the alternate password file **/
	    mlxCloseSession(altpass_lxs);
	    fdClose(altpass_fd, 0);

	    /** Did we find the user in the file? **/
	    if (found_user)
		{
		if (pwline[strlen(pwline)-1] == '\n')
		    pwline[strlen(pwline)-1] = '\0';
		pwd = pwline + strlen(username) + 1;
		encrypted_pwd = (char*)crypt(s->Password,pwd);
		if (strcmp(encrypted_pwd,pwd))
		    {
		    memset(s, 0, sizeof(MtSession));
		    nmFree(s,sizeof(MtSession));
		    return -1;
		    }
		}
	    else
		{
		memset(s, 0, sizeof(MtSession));
		nmFree(s,sizeof(MtSession));
		return -1;
		}
	    }
	else
	    {
	    mssError(1, "MSS", "Invalid auth method '%s'", MSS.AuthMethod);
	    return -1;
	    }

	/** Set the session information **/
	if (!strcmp(MSS.AuthMethod,"system"))
	    {
	    s->UserID = pw->pw_uid;
	    s->GroupID = pw->pw_gid;
	    initgroups(username, s->GroupID);
	    }
	else
	    {
	    s->UserID = geteuid();
	    s->GroupID = getegid();
	    }
	n_grps = getgroups(sizeof(grps) / sizeof(gid_t), grps);
	if (n_grps < 0 || n_grps > sizeof(grps) / sizeof(gid_t))
	    n_grps = 0;
	thSetParam(NULL,"mss",(void*)s);
	thSetParamFunctions(NULL, mssLinkSession, mssUnlinkSession);
	thSetSupplementalGroups(NULL, n_grps, grps);
	thSetGroupID(NULL,s->GroupID);
	thSetUserID(NULL,s->UserID);

	/** Initialize the error info **/
	xaInit(&(s->ErrList), 16);
	xhInit(&s->Params, 17, 0);

	/** Add to session list **/
	xaAddItem(&(MSS.Sessions), (void*)s);

    return 0;
    }