Clean up the ifdef swamp.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1609 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1997-04-20 14:10:56 +00:00
parent 7a09bebf55
commit 564f6f47cf

View File

@@ -51,11 +51,11 @@ static int (*Setpag)(void);
static int static int
isSuid() isSuid()
{ {
int uid = getuid(); int uid = getuid();
int gid = getgid(); int gid = getgid();
int euid = getegid(); int euid = getegid();
int egid = getegid(); int egid = getegid();
return (uid != euid) || (gid != egid); return (uid != euid) || (gid != egid);
} }
static int static int
@@ -92,6 +92,7 @@ aix_setup(void)
#define AIX_ENTRY_POINTS 5 #define AIX_ENTRY_POINTS 5
#define UNKNOWN_ENTRY_POINT 6 #define UNKNOWN_ENTRY_POINT 6
static int afs_entry_point = UNKNOWN_ENTRY_POINT; static int afs_entry_point = UNKNOWN_ENTRY_POINT;
static int afs_syscalls[2];
int int
@@ -101,41 +102,27 @@ k_pioctl(char *a_path,
int a_followSymlinks) int a_followSymlinks)
{ {
#ifndef NO_AFS #ifndef NO_AFS
#ifdef AFS_SYSCALL switch(afs_entry_point){
if (afs_entry_point == SINGLE_ENTRY_POINT) case SINGLE_ENTRY_POINT:
return syscall(AFS_SYSCALL, AFSCALL_PIOCTL, case SINGLE_ENTRY_POINT2:
a_path, o_opcode, a_paramsP, a_followSymlinks); case SINGLE_ENTRY_POINT3:
#endif return syscall(afs_syscalls[0], AFSCALL_PIOCTL,
a_path, o_opcode, a_paramsP, a_followSymlinks);
#ifdef AFS_PIOCTL case MULTIPLE_ENTRY_POINT:
if (afs_entry_point == MULTIPLE_ENTRY_POINT) return syscall(afs_syscalls[0],
return syscall(AFS_PIOCTL, a_path, o_opcode, a_paramsP, a_followSymlinks);
a_path, o_opcode, a_paramsP, a_followSymlinks);
#endif
#ifdef AFS_SYSCALL2
if (afs_entry_point == SINGLE_ENTRY_POINT2)
return syscall(AFS_SYSCALL2, AFSCALL_PIOCTL,
a_path, o_opcode, a_paramsP, a_followSymlinks);
#endif
#ifdef AFS_SYSCALL3
if (afs_entry_point == SINGLE_ENTRY_POINT3)
return syscall(AFS_SYSCALL3, AFSCALL_PIOCTL,
a_path, o_opcode, a_paramsP, a_followSymlinks);
#endif
#ifdef _AIX #ifdef _AIX
if (afs_entry_point == AIX_ENTRY_POINTS) case AIX_ENTRY_POINTS:
return Pioctl(a_path, o_opcode, a_paramsP, a_followSymlinks); return Pioctl(a_path, o_opcode, a_paramsP, a_followSymlinks);
#endif #endif
}
errno = ENOSYS; errno = ENOSYS;
#ifdef SIGSYS #ifdef SIGSYS
kill(getpid(), SIGSYS); /* You loose! */ kill(getpid(), SIGSYS); /* You loose! */
#endif #endif
#endif /* NO_AFS */ #endif /* NO_AFS */
return -1; return -1;
} }
int int
@@ -152,46 +139,34 @@ k_afs_cell_of_file(const char *path, char *cell, int len)
int int
k_unlog(void) k_unlog(void)
{ {
struct ViceIoctl parms; struct ViceIoctl parms;
memset(&parms, 0, sizeof(parms)); memset(&parms, 0, sizeof(parms));
return k_pioctl(0, VIOCUNLOG, &parms, 0); return k_pioctl(0, VIOCUNLOG, &parms, 0);
} }
int int
k_setpag(void) k_setpag(void)
{ {
#ifndef NO_AFS #ifndef NO_AFS
#ifdef AFS_SYSCALL switch(afs_entry_point){
if (afs_entry_point == SINGLE_ENTRY_POINT) case SINGLE_ENTRY_POINT:
return syscall(AFS_SYSCALL, AFSCALL_SETPAG); case SINGLE_ENTRY_POINT2:
#endif case SINGLE_ENTRY_POINT3:
return syscall(afs_syscalls[0], AFSCALL_SETPAG);
#ifdef AFS_SETPAG case MULTIPLE_ENTRY_POINT:
if (afs_entry_point == MULTIPLE_ENTRY_POINT) return syscall(afs_syscalls[1]);
return syscall(AFS_SETPAG);
#endif
#ifdef AFS_SYSCALL2
if (afs_entry_point == SINGLE_ENTRY_POINT2)
return syscall(AFS_SYSCALL2, AFSCALL_SETPAG);
#endif
#ifdef AFS_SYSCALL3
if (afs_entry_point == SINGLE_ENTRY_POINT3)
return syscall(AFS_SYSCALL3, AFSCALL_SETPAG);
#endif
#ifdef _AIX #ifdef _AIX
if (afs_entry_point == AIX_ENTRY_POINTS) case AIX_ENTRY_POINTS:
return Setpag(); return Setpag();
#endif #endif
}
errno = ENOSYS; errno = ENOSYS;
#ifdef SIGSYS #ifdef SIGSYS
kill(getpid(), SIGSYS); /* You loose! */ kill(getpid(), SIGSYS); /* You loose! */
#endif #endif
#endif /* NO_AFS */ #endif /* NO_AFS */
return -1; return -1;
} }
static jmp_buf catch_SIGSYS; static jmp_buf catch_SIGSYS;
@@ -201,9 +176,9 @@ static jmp_buf catch_SIGSYS;
static RETSIGTYPE static RETSIGTYPE
SIGSYS_handler(int sig) SIGSYS_handler(int sig)
{ {
errno = 0; errno = 0;
signal(SIGSYS, SIGSYS_handler); /* Need to reinstall handler on SYSV */ signal(SIGSYS, SIGSYS_handler); /* Need to reinstall handler on SYSV */
longjmp(catch_SIGSYS, 1); longjmp(catch_SIGSYS, 1);
} }
#endif #endif
@@ -211,95 +186,100 @@ SIGSYS_handler(int sig)
int int
k_hasafs(void) k_hasafs(void)
{ {
int saved_errno; int saved_errno;
RETSIGTYPE (*saved_func)(); RETSIGTYPE (*saved_func)();
struct ViceIoctl parms; struct ViceIoctl parms;
/* /*
* Already checked presence of AFS syscalls? * Already checked presence of AFS syscalls?
*/ */
if (afs_entry_point != UNKNOWN_ENTRY_POINT) if (afs_entry_point != UNKNOWN_ENTRY_POINT)
return afs_entry_point != NO_ENTRY_POINT; return afs_entry_point != NO_ENTRY_POINT;
/* /*
* Probe kernel for AFS specific syscalls, * Probe kernel for AFS specific syscalls,
* they (currently) come in two flavors. * they (currently) come in two flavors.
* If the syscall is absent we recive a SIGSYS. * If the syscall is absent we recive a SIGSYS.
*/ */
afs_entry_point = NO_ENTRY_POINT; afs_entry_point = NO_ENTRY_POINT;
memset(&parms, 0, sizeof(parms)); memset(&parms, 0, sizeof(parms));
saved_errno = errno; saved_errno = errno;
#ifndef NO_AFS #ifndef NO_AFS
#ifdef SIGSYS #ifdef SIGSYS
saved_func = signal(SIGSYS, SIGSYS_handler); saved_func = signal(SIGSYS, SIGSYS_handler);
#endif #endif
#ifdef AFS_SYSCALL #ifdef AFS_SYSCALL
if (setjmp(catch_SIGSYS) == 0) if (setjmp(catch_SIGSYS) == 0)
{
syscall(AFS_SYSCALL, AFSCALL_PIOCTL,
0, VIOCSETTOK, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (errno == EINVAL)
{ {
afs_entry_point = SINGLE_ENTRY_POINT; syscall(AFS_SYSCALL, AFSCALL_PIOCTL,
goto done; 0, VIOCSETTOK, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (errno == EINVAL)
{
afs_entry_point = SINGLE_ENTRY_POINT;
afs_syscalls[0] = AFS_SYSCALL;
goto done;
}
} }
}
#endif /* AFS_SYSCALL */ #endif /* AFS_SYSCALL */
#ifdef AFS_PIOCTL #ifdef AFS_PIOCTL
if (setjmp(catch_SIGSYS) == 0) if (setjmp(catch_SIGSYS) == 0)
{
syscall(AFS_PIOCTL,
0, VIOCSETTOK, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (errno == EINVAL)
{ {
afs_entry_point = MULTIPLE_ENTRY_POINT; syscall(AFS_PIOCTL,
goto done; 0, VIOCSETTOK, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (errno == EINVAL)
{
afs_entry_point = MULTIPLE_ENTRY_POINT;
afs_syscalls[0] = AFS_PIOCTL;
afs_syscalls[1] = AFS_SETPAG;
goto done;
}
} }
}
#endif /* AFS_PIOCTL */ #endif /* AFS_PIOCTL */
#ifdef AFS_SYSCALL2 #ifdef AFS_SYSCALL2
if (setjmp(catch_SIGSYS) == 0) if (setjmp(catch_SIGSYS) == 0)
{
syscall(AFS_SYSCALL2, AFSCALL_PIOCTL,
0, VIOCSETTOK, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (errno == EINVAL)
{ {
afs_entry_point = SINGLE_ENTRY_POINT2; syscall(AFS_SYSCALL2, AFSCALL_PIOCTL,
goto done; 0, VIOCSETTOK, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (errno == EINVAL)
{
afs_entry_point = SINGLE_ENTRY_POINT2;
afs_syscalls[0] = AFS_SYSCALL2;
goto done;
}
} }
}
#endif /* AFS_SYSCALL */ #endif /* AFS_SYSCALL */
#ifdef AFS_SYSCALL3 #ifdef AFS_SYSCALL3
if (setjmp(catch_SIGSYS) == 0) if (setjmp(catch_SIGSYS) == 0)
{
syscall(AFS_SYSCALL3, AFSCALL_PIOCTL,
0, VIOCSETTOK, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (errno == EINVAL)
{ {
afs_entry_point = SINGLE_ENTRY_POINT3; syscall(AFS_SYSCALL3, AFSCALL_PIOCTL,
goto done; 0, VIOCSETTOK, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (errno == EINVAL)
{
afs_entry_point = SINGLE_ENTRY_POINT3;
afs_syscalls[0] = AFS_SYSCALL3;
goto done;
}
} }
}
#endif /* AFS_SYSCALL */ #endif /* AFS_SYSCALL */
#ifdef _AIX #ifdef _AIX
aix_setup(); aix_setup();
if(Pioctl != NULL && Setpag != NULL){ if(Pioctl != NULL && Setpag != NULL){
afs_entry_point = AIX_ENTRY_POINTS; afs_entry_point = AIX_ENTRY_POINTS;
goto done; goto done;
} }
#endif #endif
done: done:
#ifdef SIGSYS #ifdef SIGSYS
signal(SIGSYS, saved_func); signal(SIGSYS, saved_func);
#endif #endif
#endif /* NO_AFS */ #endif /* NO_AFS */
errno = saved_errno; errno = saved_errno;
return afs_entry_point != NO_ENTRY_POINT; return afs_entry_point != NO_ENTRY_POINT;
} }