/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1990-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* authenticate fd given service authentication path
* if path==0 then it is requested from server
* otherwise if fd>=0 then state->host and state->flags are assumed valid
* only used by tcp streams
* fd<0 for remote authentication on fd 0,1
*
* csauth(state,fd,path,arg) called by csopen()
* csauth(state,-1,path,arg) called by `cs -O...'
* csauth(state,fd,0,arg) normal user call
*/
#include "cslib.h"
#include <error.h>
int
{
register char* s;
register char* t;
char* b;
char* key = 0;
int n;
int m;
int wfd;
unsigned long t1;
unsigned long t2;
if (!path)
{
if (fd < 0)
goto sorry;
goto ok;
{
goto sorry;
}
{
goto sorry;
}
buf[n - 1] = 0;
}
{
goto ok;
return -1;
}
if (fd < 0)
{
/*
* the remote side of remote authentication
*/
fd = 0;
wfd = 1;
}
m = getpid();
{
if (s < b)
{
*s++ = ' ';
while (s < b && *t)
if ((*s++ = *t++) == '/' && *t == '#' && *++t != '#')
*(s - 1) = ' ';
}
}
*s++ = '\n';
n = s - tmp;
{
goto sorry;
}
{
goto sorry;
}
if (*num != '\n')
{
n = 0;
if (state->addr == csaddr(state, NiL)) b = tmp + sfsprintf(tmp, sizeof(tmp), "%s/AUTH.%05d.", csvar(state, CS_VAR_LOCAL, 0), m);
else
{
while (s > (char*)path)
if (*--s == '/' && ++n >= 4) break;
if (n != 4) goto sorry;
}
{
*s = 0;
if (eaccess(tmp, X_OK) && (mkdir(tmp, S_IRWXU|S_IRWXG|S_IRWXO) || chmod(tmp, S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)))
{
goto sorry;
}
*s = '/';
}
t1 -= CS_STAT_DOWN;
n = auth;
for (;;)
{
if (auth == n)
{
goto sorry;
}
if ((stat(tmp, &st) || t1 <= (unsigned long)st.st_ctime && !remove(tmp)) && !close(open(tmp, O_CREAT|O_TRUNC|O_cloexec, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH))) break;
}
{
goto sorry;
}
goto sorry;
{
goto sorry;
}
t = s;
if (arg)
{
if (s < b)
{
*s++ = ' ';
while (s < b && *arg)
{
arg++;
*(s - 1) = ' ';
}
}
}
*s++ = '\n';
*t = 0;
if (n != s - tmp)
{
goto sorry;
}
{
goto sorry;
}
{
goto sorry;
}
}
ok:
return 0;
return -1;
}
/*
* set up the challenge {v1,v2} on path
*/
int
{
{
return -1;
}
{
return -1;
}
if (v1)
if (v2)
return 0;
}
int
{
}
int
{
}