- Not longer needed.

This commit is contained in:
michael 1998-09-18 14:47:10 +00:00
parent e2dda05c75
commit 23738857f2
2 changed files with 0 additions and 243 deletions

View File

@ -1,205 +0,0 @@
/*
** $Id: userrc.c,v 1.3 1998/08/31 15:30:42 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
**
** $Log: userrc.c,v $
** Revision 1.3 1998/08/31 15:30:42 michael
** - Added touchtone support.
** - Added new tcl command "vbox_breaklist" to clear/set the touchtone
** breaklist.
** - Removed the audio fragment size setting again. I don't know why this
** crash my machine. The fragment size setting can be enabled in audio.h
** with a define.
**
** Revision 1.2 1998/08/31 10:43:14 michael
** - Changed "char" to "unsigned char".
**
** Revision 1.1 1998/07/06 09:05:33 michael
** - New control file code added. The controls are not longer only empty
** files - they can contain additional informations.
** - Control "vboxctrl-answer" added.
** - Control "vboxctrl-suspend" added.
** - Locking mechanism added.
** - Configuration parsing added.
** - Some code cleanups.
**
*/
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif
#include <stdio.h>
#include <string.h>
#include <fnmatch.h>
#include <pwd.h>
#include <grp.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "userrc.h"
#include "rc.h"
#include "stringutils.h"
#include "vboxgetty.h"
#include "log.h"
/*************************************************************************/
/** userrc_parse(): Liest die Datei "vboxgetty.user" ein. **/
/*************************************************************************/
/** => vboxuser Zeiger auf die User-Struktur. **/
/** => home Spoolverzeichnis des Benutzers. **/
/** => phone Lokale Telefonnummer die einem Benutzer zugewiesen **/
/** werden soll. **/
/** **/
/** <= 0 wenn die Nummer einem Benutzer zugeordnet werden **/
/** konnte oder -1 bei einem Fehler. **/
/*************************************************************************/
int userrc_parse(struct vboxuser *vboxuser, unsigned char *home, unsigned char *phone)
{
struct passwd *pwdent;
struct group *grpent;
unsigned char line[USERRC_MAX_RCLINE + 1];
FILE *rc;
unsigned char *stop;
unsigned char *pattern;
unsigned char *group;
unsigned char *name;
unsigned char *space;
unsigned char *mask;
int linenr;
int havegroup;
log_line(LOG_D, "Searching local user for number %s...\n", phone);
printstring(temppathname, "%s/vboxgetty.user", SYSCONFDIR);
if ((rc = fopen(temppathname, "r")))
{
linenr = 0;
while (fgets(line, USERRC_MAX_RCLINE, rc))
{
linenr++;
line[strlen(line) - 1] = '\0';
if ((*line == '\0') || (*line == '#')) continue;
pattern = strtok(line, ":");
name = strtok(NULL, ":");
group = strtok(NULL, ":");
mask = strtok(NULL, ":");
space = strtok(NULL, ":");
if ((!pattern) || (!name) || (!group) || (!mask) || (!space))
{
log_line(LOG_E, "Error in \"%s\" line %d.\n", temppathname, linenr);
break;
}
if (fnmatch(pattern, vboxuser->localphone, 0) == 0)
{
log_line(LOG_D, "Found - number matchs pattern \"%s\".\n", pattern);
if (!*name)
{
log_line(LOG_E, "You *must* specify a user name or a user id!\n");
break;
}
if (*name == '#')
pwdent = getpwuid((uid_t)xstrtol(&name[1], 0));
else
pwdent = getpwnam(name);
if (!pwdent)
{
log_line(LOG_E, "Unable to locate \"%s\" in systems passwd list.\n", name);
break;
}
vboxuser->uid = pwdent->pw_uid;
vboxuser->gid = pwdent->pw_gid;
if ((strlen(home) + strlen(pwdent->pw_name) + 2) < (PATH_MAX - 100))
{
xstrncpy(vboxuser->name, pwdent->pw_name, VBOXUSER_USERNAME);
printstring(vboxuser->home, "%s/%s", home, pwdent->pw_name);
}
else
{
log_line(LOG_E, "Oops! Spool directory name and user name too long!\n");
break;
}
if (*group)
{
havegroup = 0;
setgrent();
while ((grpent = getgrent()))
{
if (*group == '#')
{
if (grpent->gr_gid == (gid_t)xstrtol(&group[1], 0))
{
vboxuser->gid = grpent->gr_gid;
havegroup = 1;
break;
}
}
else
{
if (strcmp(grpent->gr_name, group) == 0)
{
vboxuser->gid = grpent->gr_gid;
havegroup = 1;
break;
}
}
}
endgrent();
if (!havegroup)
{
log_line(LOG_E, "Unable to locate \"%s\" in systems group list.\n", group);
break;
}
}
vboxuser->space = xstrtol(space, 0);
vboxuser->umask = (mode_t)strtol(mask, (char **)&stop, 8);
if (*stop != '\0')
{
log_line(LOG_E, "Illegal umask \"%s\" in line %d.\n", mask, linenr);
break;
}
fclose(rc);
log_line(LOG_D, "User \"%s\" (%d.%d) will be used...\n", vboxuser->name, vboxuser->uid, vboxuser->gid);
return(0);
}
}
fclose(rc);
}
else log_line(LOG_W, "Can't open \"%s\".\n", temppathname);
return(-1);
}

View File

@ -1,38 +0,0 @@
/*
** $Id: userrc.h,v 1.2 1998/08/31 10:43:15 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
*/
#ifndef _USERRC_H
#define _USERRC_H 1
#include <limits.h>
/** Defines **************************************************************/
#define USERRC_MAX_RCLINE 255
#define VBOXUSER_CALLID 64
#define VBOXUSER_NUMBER 64
#define VBOXUSER_USERNAME 64
/** Structures ***********************************************************/
struct vboxuser
{
uid_t uid;
gid_t gid;
int umask;
long space;
unsigned char incomingid[VBOXUSER_CALLID + 1];
unsigned char localphone[VBOXUSER_NUMBER + 1];
unsigned char name[VBOXUSER_USERNAME + 1];
unsigned char home[PATH_MAX + 1];
};
/** Prototypes ***********************************************************/
extern int userrc_parse(struct vboxuser *, unsigned char *, unsigned char *);
#endif /* _USERRC_H */