#include "afs/auth.h"
#include "afs/cellconfig.h"
#include "afs/vice.h"
-#include "afs/kauth.h"
-#include "afs/kautils.h"
#include "afs/afsutil.h"
#include "afs/afs_bypasscache.h"
#include "rx/rx_globals.h"
afs_lock_t osi_flplock;
afs_lock_t osi_fsplock;
-#ifndef NETSCAPE_NSAPI
-
/*
* Mutex and condition variable used to implement sleep
*/
pthread_mutex_t usr_sleep_mutex;
pthread_cond_t usr_sleep_cond;
-#endif /* !NETSCAPE_NSAPI */
-
int call_syscall(long, long, long, long, long, long);
int fork_syscall(long, long, long, long, long, long);
{
struct usr_user *uptr;
int st;
- st = usr_getspecific(afs_global_u_key, (void **)&uptr);
+
+ st = usr_getspecific(afs_global_u_key, &uptr);
usr_assert(st == 0);
if (uptr == NULL) {
uafs_InitThread();
- st = usr_getspecific(afs_global_u_key, (void **)&uptr);
+ st = usr_getspecific(afs_global_u_key, &uptr);
usr_assert(st == 0);
usr_assert(uptr != NULL);
}
afs_global_procp->p_ppid = (pid_t) 1;
afs_global_procp->p_ucred = afs_global_ucredp;
-#ifndef NETSCAPE_NSAPI
/*
* Initialize the mutex and condition variable used to implement
* time sleeps.
*/
pthread_mutex_init(&usr_sleep_mutex, NULL);
pthread_cond_init(&usr_sleep_cond, NULL);
-#endif /* !NETSCAPE_NSAPI */
/*
* Initialize the hash table used for sleep/wakeup
long param4;
};
-#ifdef NETSCAPE_NSAPI
-void
-syscallThread(void *argp)
-#else /* NETSCAPE_NSAPI */
void *
syscallThread(void *argp)
-#endif /* NETSCAPE_NSAPI */
{
int i;
struct usr_ucred *crp;
}
/*
+ * Lookup the target of a symbolic link
+ * Call VN_HOLD on the output vnode if successful.
+ * Returns zero on success, error code on failure.
+ * If provided, use a path for confirming we are not linked to ourself.
+ *
+ * Note: Caller must hold the AFS global lock.
+ */
+static int
+uafs_LookupLinkPath(struct usr_vnode *vp, struct usr_vnode *parentVp,
+ char *ppathP, struct usr_vnode **vpp)
+{
+ int code;
+ int len;
+ char *pathP;
+ struct usr_vnode *linkVp;
+ struct usr_uio uio;
+ struct iovec iov[1];
+
+ AFS_ASSERT_GLOCK();
+
+ pathP = afs_osi_Alloc(MAX_OSI_PATH + 1);
+ usr_assert(pathP != NULL);
+
+ /*
+ * set up the uio buffer
+ */
+ iov[0].iov_base = pathP;
+ iov[0].iov_len = MAX_OSI_PATH + 1;
+ uio.uio_iov = &iov[0];
+ uio.uio_iovcnt = 1;
+ uio.uio_offset = 0;
+ uio.uio_segflg = 0;
+ uio.uio_fmode = FREAD;
+ uio.uio_resid = MAX_OSI_PATH + 1;
+
+ /*
+ * Read the link data
+ */
+ code = afs_readlink(VTOAFS(vp), &uio, get_user_struct()->u_cred);
+ if (code) {
+ afs_osi_Free(pathP, MAX_OSI_PATH + 1);
+ return code;
+ }
+ len = MAX_OSI_PATH + 1 - uio.uio_resid;
+ pathP[len] = '\0';
+
+ /* are we linked to ourname or ./ourname? ELOOP */
+ if (ppathP) {
+ if ((strcmp(pathP, ppathP) == 0) ||
+ ((pathP[0] == '.') &&
+ (pathP[1] == '/') &&
+ (strcmp(&(pathP[2]), ppathP) == 0))) {
+ return ELOOP;
+ }
+ }
+
+ /*
+ * Find the target of the symbolic link
+ */
+ code = uafs_LookupName(pathP, parentVp, &linkVp, 1, 0);
+ if (code) {
+ afs_osi_Free(pathP, MAX_OSI_PATH + 1);
+ return code;
+ }
+
+ afs_osi_Free(pathP, MAX_OSI_PATH + 1);
+ *vpp = linkVp;
+ return 0;
+}
+
+/*
* Lookup a file or directory given its path.
* Call VN_HOLD on the output vnode if successful.
* Returns zero on success, error code on failure.
afs_osi_Free(tmpPath, strlen(path) + 1);
return code;
}
- code = uafs_LookupLink(nextVp, vp, &linkVp);
+ code = uafs_LookupLinkPath(nextVp, vp, NULL, &linkVp);
if (code) {
VN_RELE(vp);
VN_RELE(nextVp);
return 0;
}
-/*
- * Lookup the target of a symbolic link
- * Call VN_HOLD on the output vnode if successful.
- * Returns zero on success, error code on failure.
- *
- * Note: Caller must hold the AFS global lock.
- */
int
uafs_LookupLink(struct usr_vnode *vp, struct usr_vnode *parentVp,
struct usr_vnode **vpp)
{
- int code;
- int len;
- char *pathP;
- struct usr_vnode *linkVp;
- struct usr_uio uio;
- struct iovec iov[1];
-
- AFS_ASSERT_GLOCK();
-
- pathP = afs_osi_Alloc(MAX_OSI_PATH + 1);
- usr_assert(pathP != NULL);
-
- /*
- * set up the uio buffer
- */
- iov[0].iov_base = pathP;
- iov[0].iov_len = MAX_OSI_PATH + 1;
- uio.uio_iov = &iov[0];
- uio.uio_iovcnt = 1;
- uio.uio_offset = 0;
- uio.uio_segflg = 0;
- uio.uio_fmode = FREAD;
- uio.uio_resid = MAX_OSI_PATH + 1;
-
- /*
- * Read the link data
- */
- code = afs_readlink(VTOAFS(vp), &uio, get_user_struct()->u_cred);
- if (code) {
- afs_osi_Free(pathP, MAX_OSI_PATH + 1);
- return code;
- }
- len = MAX_OSI_PATH + 1 - uio.uio_resid;
- pathP[len] = '\0';
-
- /*
- * Find the target of the symbolic link
- */
- code = uafs_LookupName(pathP, parentVp, &linkVp, 1, 0);
- if (code) {
- afs_osi_Free(pathP, MAX_OSI_PATH + 1);
- return code;
- }
-
- afs_osi_Free(pathP, MAX_OSI_PATH + 1);
- *vpp = linkVp;
- return 0;
+ return uafs_LookupLinkPath(vp, parentVp, NULL, vpp);
}
/*
/* these get freed in PrefetchNoCache, so... */
bparms = afs_osi_Alloc(sizeof(struct nocache_read_request));
- bparms->areq = afs_osi_Alloc(sizeof(struct vrequest));
- afs_InitReq(bparms->areq, get_user_struct()->u_cred);
+ code = afs_CreateReq(&bparms->areq, get_user_struct()->u_cred);
+ if (code) {
+ afs_DestroyReq(bparms->areq);
+ afs_osi_Free(bparms, sizeof(struct nocache_read_request));
+ errno = code;
+ return -1;
+ }
bparms->auio = &uio;
bparms->offset = offset;
attrs.va_mode = 0777;
attrs.va_uid = afs_cr_uid(get_user_struct()->u_cred);
attrs.va_gid = afs_cr_gid(get_user_struct()->u_cred);
- code = afs_symlink(VTOAFS(dirP), nameP, &attrs, target, get_user_struct()->u_cred);
+ code = afs_symlink(VTOAFS(dirP), nameP, &attrs, target, NULL,
+ get_user_struct()->u_cred);
VN_RELE(dirP);
if (code != 0) {
errno = code;
}
/*
- * Do AFS authentication
- */
-int
-uafs_klog(char *user, char *cell, char *passwd, char **reason)
-{
- int code;
- afs_int32 password_expires = -1;
-
- usr_mutex_lock(&osi_authenticate_lock);
- code =
- ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION +
- KA_USERAUTH_DOSETPAG2, user, NULL, cell,
- passwd, 0, &password_expires, 0, reason);
- usr_mutex_unlock(&osi_authenticate_lock);
- return code;
-}
-
-int
-uafs_klog_r(char *user, char *cell, char *passwd, char **reason)
-{
- int retval;
- AFS_GUNLOCK();
- retval = uafs_klog(user, cell, passwd, reason);
- AFS_GLOCK();
- return retval;
-}
-
-/*
* Destroy AFS credentials from the kernel cache
*/
int
}
/*
- * uafs_klog_nopag
- * klog but don't allocate a new pag
- */
-int
-uafs_klog_nopag(char *user, char *cell, char *passwd, char **reason)
-{
- int code;
- afs_int32 password_expires = -1;
-
- usr_mutex_lock(&osi_authenticate_lock);
- code = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION
- /*+KA_USERAUTH_DOSETPAG2 */ , user,
- NULL, cell, passwd, 0,
- &password_expires, 0, reason);
- usr_mutex_unlock(&osi_authenticate_lock);
- return code;
-}
-
-/*
* uafs_getcellstatus
* get the cell status
*/
{
int rc;
struct afs_ioctl iob;
- VolumeStatus *status;
- char buf[1024];
+ VolumeStatus status;
iob.in = 0;
iob.in_size = 0;
- iob.out = buf;
- iob.out_size = 1024;
+ iob.out = (char *)&status;
+ iob.out_size = sizeof status;
rc = call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(4), (long)&iob,
0, 0);
return -1;
}
- status = (VolumeStatus *) buf;
- *BlocksInUse = status->BlocksInUse;
- *MaxQuota = status->MaxQuota;
+ *BlocksInUse = status.BlocksInUse;
+ *MaxQuota = status.MaxQuota;
return 0;
}
{
int rc;
struct afs_ioctl iob;
- VolumeStatus *status;
- char buf[1024];
+ VolumeStatus status = { 0 };
- iob.in = buf;
- iob.in_size = 1024;
+ iob.in = (char *)&status;
+ iob.in_size = sizeof status;
iob.out = 0;
iob.out_size = 0;
- memset(buf, 0, sizeof(VolumeStatus));
- status = (VolumeStatus *) buf;
- status->MaxQuota = MaxQuota;
- status->MinQuota = -1;
+ status.MaxQuota = MaxQuota;
+ status.MinQuota = -1;
rc = call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(5), (long)&iob,
0, 0);