#define PREV_FSTAT 28
#define PAUSE 29
#define UTIME 30
+#define GETEPINFO 31
+#define SETGROUPS 32
#define ACCESS 33
+#define GETGROUPS 34
#define SYNC 36
#define KILL 37
#define RENAME 38
#define SETSID 62
#define GETPGRP 63
#define ITIMER 64
-#define GETGROUPS 65
-#define SETGROUPS 66
+#define GETGROUPS_O 65
+#define SETGROUPS_O 66
#define GETMCONTEXT 67
#define SETMCONTEXT 68
#define PROCSTAT 103 /* to PM */
#define GETPROCNR 104 /* to PM */
-#define GETEPINFO 107 /* to PM: get pid/uid/gid of an endpoint */
+#define GETEPINFO_O 107 /* to PM: get pid/uid/gid of an endpoint */
#define ADDDMA 108 /* to PM: inform PM about a region of memory
* that is used for bus-master DMA
*/
#define IOV_MAX INT_MAX /* maximum number of buffers for readv/writev */
#endif /* _POSIX_SOURCE */
+#define GID_MAX USHRT_MAX
+#define UID_MAX USHRT_MAX
+
#endif /* _LIMITS_H */
/* Types used in disk, inode, etc. data structures.
* Some u64_t should be i64_t, but anyway with old libc we use .lo only.
*/
-typedef char gid_t; /* group id */
+typedef u32_t gid_t; /* group id */
typedef u32_t big_gid_t; /* group id */
typedef unsigned long ino_t; /* i-node number (V3 filesystem) */
typedef u64_t big_ino_t; /* i-node number (V3 filesystem) */
typedef long off_t; /* offset within a file */
typedef u64_t big_off_t; /* offset within a file */
typedef int pid_t; /* process id (must be signed) */
-typedef short uid_t; /* user id */
+typedef u32_t uid_t; /* user id */
typedef u32_t big_uid_t; /* user id */
typedef unsigned long fsblkcnt_t; /* File system block count */
typedef unsigned long fsfilcnt_t; /* File system file count */
/* setsockopt/setsockopt for unix domain sockets */
#define NWIOGUDSSOTYPE _IOR('n', 90, int) /* SO_TYPE */
+#define NWIOGUDSPEERCREDOLD _IOR('n', 91, struct ucred_old) /* SO_PEERCRED */
#define NWIOGUDSPEERCRED _IOR('n', 91, struct ucred) /* SO_PEERCRED */
#define NWIOGUDSSNDBUF _IOR('n', 92, size_t) /* SO_SNDBUF */
#define NWIOSUDSSNDBUF _IOW('n', 93, size_t) /* SO_SNDBUF */
ino_t st_ino; /* i-node number */
mode_t st_mode; /* file mode, protection bits, etc. */
nlink_t st_nlink; /* # links; */
- uid_t st_uid; /* uid of the file's owner */
+ short st_uid; /* uid of the file's owner */
short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */
short st_rdev;
off_t st_size; /* file size */
#ifndef __SYS_UCRED_H
#define __SYS_UCRED_H
-struct ucred
+struct ucred_old
{
pid_t pid;
- uid_t uid;
- gid_t gid;
+ short uid;
+ char gid;
+};
+
+struct ucred
+{
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
};
#endif
if (direction == READING) {
/* Copy V2.x inode to the in-core table, swapping bytes if need be. */
rip->i_mode = conv2(norm,dip->d2_mode);
- rip->i_uid = conv2(norm,dip->d2_uid );
+ rip->i_uid = conv4(norm,dip->d2_uid );
rip->i_nlinks = conv2(norm,(int) dip->d2_nlinks);
- rip->i_gid = conv2(norm,(int) dip->d2_gid );
+ rip->i_gid = conv4(norm,(int) dip->d2_gid );
rip->i_size = conv4(norm,dip->d2_size);
rip->i_atime = conv4(norm,dip->d2_atime);
rip->i_ctime = conv4(norm,dip->d2_ctime);
} else {
/* Copying V2.x inode to disk from the in-core table. */
dip->d2_mode = conv2(norm,rip->i_mode);
- dip->d2_uid = conv2(norm,rip->i_uid );
+ dip->d2_uid = conv4(norm,rip->i_uid );
dip->d2_nlinks = conv2(norm,rip->i_nlinks);
- dip->d2_gid = conv2(norm,rip->i_gid );
+ dip->d2_gid = conv4(norm,rip->i_gid );
dip->d2_size = conv4(norm,rip->i_size);
dip->d2_atime = conv4(norm,rip->i_atime);
dip->d2_ctime = conv4(norm,rip->i_ctime);
{
message m;
m.m1_i1 = ngroups;
- m.m1_p1 = arr;
+ m.m1_p1 = (char *) arr;
return(_syscall(PM_PROC_NR, GETGROUPS, &m));
}
_files_getgrgid(void *nsrv, void *nscb, va_list ap)
{
struct group **retval = va_arg(ap, struct group **);
-#ifdef __minix
- gid_t gid = (gid_t)va_arg(ap, int);
-#else
gid_t gid = va_arg(ap, gid_t);
-#endif
int rv, rerror;
_files_getgrgid_r(void *nsrv, void *nscb, va_list ap)
{
int *retval = va_arg(ap, int *);
-#ifdef __minix
- gid_t gid = (gid_t)va_arg(ap, int);
-#else
gid_t gid = va_arg(ap, gid_t);
-#endif
struct group *grp = va_arg(ap, struct group *);
char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t);
_dns_getgrgid(void *nsrv, void *nscb, va_list ap)
{
struct group **retval = va_arg(ap, struct group **);
-#ifdef __minix
- gid_t gid = (gid_t)va_arg(ap, int);
-#else
gid_t gid = va_arg(ap, gid_t);
-#endif
int rv, rerror;
_dns_getgrgid_r(void *nsrv, void *nscb, va_list ap)
{
int *retval = va_arg(ap, int *);
-#ifdef __minix
- gid_t gid = (gid_t)va_arg(ap, int);
-#else
gid_t gid = va_arg(ap, gid_t);
-#endif
struct group *grp = va_arg(ap, struct group *);
char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t);
_nis_getgrgid(void *nsrv, void *nscb, va_list ap)
{
struct group **retval = va_arg(ap, struct group **);
-#ifdef __minix
- gid_t gid = (gid_t)va_arg(ap, int);
-#else
gid_t gid = va_arg(ap, gid_t);
-#endif
int rv, rerror;
_nis_getgrgid_r(void *nsrv, void *nscb, va_list ap)
{
int *retval = va_arg(ap, int *);
-#ifdef __minix
- gid_t gid = (gid_t)va_arg(ap, int);
-#else
gid_t gid = va_arg(ap, gid_t);
-#endif
struct group *grp = va_arg(ap, struct group *);
char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t);
crv = nsdispatch(NULL, compatgiddtab,
NSDB_GROUP_COMPAT, "getgrgid_r",
__nsdefaultnis,
-#ifdef __minix
- &cretval, (int)gid,
-#else
&cretval, gid,
-#endif
&cgrp, filebuf, sizeof(filebuf), &cgrpres);
}
if (crv != NS_SUCCESS) { /* not found */
_compat_getgrgid(void *nsrv, void *nscb, va_list ap)
{
struct group **retval = va_arg(ap, struct group **);
-#ifdef __minix
- gid_t gid = (gid_t)va_arg(ap, int);
-#else
gid_t gid = va_arg(ap, gid_t);
-#endif
int rv, rerror;
_compat_getgrgid_r(void *nsrv, void *nscb, va_list ap)
{
int *retval = va_arg(ap, int *);
-#ifdef __minix
- gid_t gid = (gid_t)va_arg(ap, int);
-#else
gid_t gid = va_arg(ap, gid_t);
-#endif
struct group *grp = va_arg(ap, struct group *);
char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t);
mutex_lock(&__grmutex);
rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid", __nsdefaultcompat,
-#ifdef __minix
- &retval, (int)gid);
-#else
&retval, gid);
-#endif
mutex_unlock(&__grmutex);
return (rv == NS_SUCCESS) ? retval : NULL;
}
retval = 0;
mutex_lock(&__grmutex);
rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid_r", __nsdefaultcompat,
-#ifdef __minix
- &retval, (int)gid, grp, buffer, buflen, result);
-#else
&retval, gid, grp, buffer, buflen, result);
-#endif
mutex_unlock(&__grmutex);
switch (rv) {
case NS_SUCCESS:
{
int *result = va_arg(ap, int *);
const char *uname = va_arg(ap, const char *);
-#ifdef __minix
- gid_t agroup = (gid_t)va_arg(ap, int);
-#else
gid_t agroup = va_arg(ap, gid_t);
-#endif
gid_t *groups = va_arg(ap, gid_t *);
int maxgrp = va_arg(ap, int);
int *groupc = va_arg(ap, int *);
{
int *result = va_arg(ap, int *);
const char *uname = va_arg(ap, const char *);
-#ifdef __minix
- gid_t agroup = (gid_t)va_arg(ap, int);
-#else
gid_t agroup = va_arg(ap, gid_t);
-#endif
gid_t *groups = va_arg(ap, gid_t *);
int maxgrp = va_arg(ap, int);
int *groupc = va_arg(ap, int *);
{
int *result = va_arg(ap, int *);
const char *uname = va_arg(ap, const char *);
-#ifdef __minix
- gid_t agroup = (gid_t)va_arg(ap, int);
-#else
gid_t agroup = va_arg(ap, gid_t);
-#endif
gid_t *groups = va_arg(ap, gid_t *);
int maxgrp = va_arg(ap, int);
int *groupc = va_arg(ap, int *);
crv = nsdispatch(NULL, dtab,
NSDB_GROUP_COMPAT, "getgroupmembership",
__nsdefaultnis,
-#ifdef __minix
- &rerror, cp->uname, (int)cp->agroup, cp->groups, cp->maxgrp, cp->groupc);
-#else
&rerror, cp->uname, cp->agroup, cp->groups, cp->maxgrp, cp->groupc);
-#endif
if (crv == NS_SUCCESS)
crv = NS_NOTFOUND; /* indicate "no more +: entries" */
{
int *result = va_arg(ap, int *);
const char *uname = va_arg(ap, const char *);
-#ifdef __minix
- gid_t agroup = (gid_t)va_arg(ap, int);
-#else
gid_t agroup = va_arg(ap, gid_t);
-#endif
gid_t *groups = va_arg(ap, gid_t *);
int maxgrp = va_arg(ap, int);
int *groupc = va_arg(ap, int *);
*/
(void) nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership",
__nsdefaultcompat,
-#ifdef __minix
- &rerror, uname, (int)agroup, groups, maxgrp, groupc);
-#else
&rerror, uname, agroup, groups, maxgrp, groupc);
-#endif
mutex_unlock(&__grmutex);
if (*groupc > maxgrp) /* too many groups found */
_files_getpwuid(void *nsrv, void *nscb, va_list ap)
{
struct passwd **retval = va_arg(ap, struct passwd **);
-#ifdef __minix
- uid_t uid = (uid_t)va_arg(ap, int);
-#else
uid_t uid = va_arg(ap, uid_t);
-#endif
int rv, rerror;
_files_getpwuid_r(void *nsrv, void *nscb, va_list ap)
{
int *retval = va_arg(ap, int *);
-#ifdef __minix
- uid_t uid = (uid_t)va_arg(ap, int);
-#else
uid_t uid = va_arg(ap, uid_t);
-#endif
struct passwd *pw = va_arg(ap, struct passwd *);
char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t);
_dns_getpwuid(void *nsrv, void *nscb, va_list ap)
{
struct passwd **retval = va_arg(ap, struct passwd **);
-#ifdef __minix
- uid_t uid = (uid_t)va_arg(ap, int);
-#else
uid_t uid = va_arg(ap, uid_t);
-#endif
int rv, rerror;
_dns_getpwuid_r(void *nsrv, void *nscb, va_list ap)
{
int *retval = va_arg(ap, int *);
-#ifdef __minix
- uid_t uid = (uid_t)va_arg(ap, int);
-#else
uid_t uid = va_arg(ap, uid_t);
-#endif
struct passwd *pw = va_arg(ap, struct passwd *);
char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t);
_nis_getpwuid(void *nsrv, void *nscb, va_list ap)
{
struct passwd **retval = va_arg(ap, struct passwd **);
-#ifdef __minix
- uid_t uid = (uid_t)va_arg(ap, int);
-#else
uid_t uid = va_arg(ap, uid_t);
-#endif
int rv, rerror;
_nis_getpwuid_r(void *nsrv, void *nscb, va_list ap)
{
int *retval = va_arg(ap, int *);
-#ifdef __minix
- uid_t uid = (uid_t)va_arg(ap, int);
-#else
uid_t uid = va_arg(ap, uid_t);
-#endif
struct passwd *pw = va_arg(ap, struct passwd *);
char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t);
&crv, name, pw, buffer, buflen, &cpw);
break;
case _PW_KEYBYUID:
-#ifdef __minix
- rv = nsdispatch(NULL, compatuiddtab,
- NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis,
- &crv, (int)uid, pw, buffer, buflen, &cpw);
-#else
rv = nsdispatch(NULL, compatuiddtab,
NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis,
&crv, uid, pw, buffer, buflen, &cpw);
-#endif
break;
default:
abort();
_compat_getpwuid(void *nsrv, void *nscb, va_list ap)
{
struct passwd **retval = va_arg(ap, struct passwd **);
-#ifdef __minix
- uid_t uid = (uid_t)va_arg(ap, int);
-#else
uid_t uid = va_arg(ap, uid_t);
-#endif
int rv, rerror;
_compat_getpwuid_r(void *nsrv, void *nscb, va_list ap)
{
int *retval = va_arg(ap, int *);
-#ifdef __minix
- uid_t uid = (uid_t)va_arg(ap, int);
-#else
uid_t uid = va_arg(ap, uid_t);
-#endif
struct passwd *pw = va_arg(ap, struct passwd *);
char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t);
};
mutex_lock(&_pwmutex);
-#ifdef __minix
- rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat,
- &retval, (int)uid);
-#else
rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat,
&retval, uid);
-#endif
mutex_unlock(&_pwmutex);
return (rv == NS_SUCCESS) ? retval : NULL;
}
*result = NULL;
retval = 0;
mutex_lock(&_pwmutex);
-#ifdef __minix
- r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat,
- &retval, (int)uid, pwd, buffer, buflen, result);
-#else
r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat,
&retval, uid, pwd, buffer, buflen, result);
-#endif
mutex_unlock(&_pwmutex);
switch (r) {
if (direction == READING) {
/* Copy V2.x inode to the in-core table, swapping bytes if need be. */
rip->i_mode = conv2(norm,dip->d2_mode);
- rip->i_uid = conv2(norm,dip->d2_uid );
+ rip->i_uid = conv4(norm,dip->d2_uid );
rip->i_nlinks = conv2(norm,(int) dip->d2_nlinks);
- rip->i_gid = conv2(norm,(int) dip->d2_gid );
+ rip->i_gid = conv4(norm,(int) dip->d2_gid );
rip->i_size = conv4(norm,dip->d2_size);
rip->i_atime = conv4(norm,dip->d2_atime);
rip->i_ctime = conv4(norm,dip->d2_ctime);
} else {
/* Copying V2.x inode to disk from the in-core table. */
dip->d2_mode = conv2(norm,rip->i_mode);
- dip->d2_uid = conv2(norm,rip->i_uid );
+ dip->d2_uid = conv4(norm,rip->i_uid );
dip->d2_nlinks = conv2(norm,rip->i_nlinks);
- dip->d2_gid = conv2(norm,rip->i_gid );
+ dip->d2_gid = conv4(norm,rip->i_gid );
dip->d2_size = conv4(norm,rip->i_size);
dip->d2_atime = conv4(norm,rip->i_atime);
dip->d2_ctime = conv4(norm,rip->i_ctime);
#include <machine/ansi.h>
typedef char * __caddr_t; /* core address */
-typedef char __gid_t; /* group id */
+typedef __uint32_t __gid_t; /* group id */
typedef __uint32_t __in_addr_t; /* IP(v4) address */
typedef __uint16_t __in_port_t; /* "Internet" port number */
typedef unsigned short __mode_t; /* file permissions */
typedef int __pid_t; /* process id */
typedef __uint8_t __sa_family_t; /* socket address family */
typedef __int32_t __socklen_t; /* socket-related datum length */
-typedef short __uid_t; /* user id */
+typedef __uint32_t __uid_t; /* user id */
typedef unsigned long __fsblkcnt_t; /* fs block count (statvfs) */
typedef unsigned long __fsfilcnt_t; /* fs file count */
ino_t st_ino; /* i-node number */
mode_t st_mode; /* file mode, protection bits, etc. */
nlink_t st_nlink; /* # links; */
- uid_t st_uid; /* uid of the file's owner */
+ short st_uid; /* uid of the file's owner */
short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */
short st_rdev;
off_t st_size; /* file size */
#define CHILD_MAX _NO_LIMIT /* max simultaneous processes */
#endif
-#define GID_MAX CHAR_MAX /* max value for a gid_t */
+#define GID_MAX USHRT_MAX /* max value for a gid_t */
#define LINK_MAX SHRT_MAX /* # links a file may have */
#define MAX_CANON 255 /* size of the canonical input queue */
#define MAX_INPUT 255 /* size of the type-ahead buffer */
#define NAME_MAX 255 /* system-wide max # chars in a file name */
#define NGROUPS_MAX 8 /* max. number of supplemental groups */
-#define UID_MAX SHRT_MAX /* max value for a uid_t */
+#define UID_MAX USHRT_MAX /* max value for a uid_t */
#ifndef OPEN_MAX
#define OPEN_MAX __MINIX_OPEN_MAX /* max open files per process */
#endif
#ifndef __SYS_UCRED_H
#define __SYS_UCRED_H
-#include <sys/types.h>
+struct ucred_old
+{
+ pid_t pid;
+ short uid;
+ char gid;
+};
struct ucred
{
- pid_t pid;
- uid_t uid;
- gid_t gid;
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
};
#endif
break;
+ case NWIOGUDSPEERCREDOLD:
+
+ /* get peer endpoint -- getsockopt(SO_PEERCRED) */
+ rc = do_getsockopt_peercred_old(dev_m_in, dev_m_out);
+
+ break;
+
case NWIOSUDSTADDR:
/* set target address -- sendto() */
(message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_getsockopt_peercred,
(message *dev_m_in, message *dev_m_out) );
+_PROTOTYPE( int do_getsockopt_peercred_old,
+ (message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_getsockopt_sndbuf,
(message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_setsockopt_sndbuf,
return rc ? EIO : OK;
}
+PUBLIC int do_getsockopt_peercred_old(message *dev_m_in, message *dev_m_out)
+{
+ int minor;
+ int peer_minor;
+ int rc;
+ struct ucred cred;
+ struct ucred_old cred_old;
+
+#if DEBUG == 1
+ static int call_count = 0;
+ printf("(uds) [%d] do_getsockopt_peercred() call_count=%d\n",
+ uds_minor(dev_m_in), ++call_count);
+#endif
+
+ minor = uds_minor(dev_m_in);
+
+ if (uds_fd_table[minor].peer == -1) {
+
+ if (uds_fd_table[minor].err == ECONNRESET) {
+ uds_fd_table[minor].err = 0;
+
+ return ECONNRESET;
+ } else {
+ return ENOTCONN;
+ }
+ }
+
+ peer_minor = uds_fd_table[minor].peer;
+
+ /* obtain the peer's credentials */
+ rc = getnucred(uds_fd_table[peer_minor].owner, &cred);
+ if (rc == -1) {
+ /* likely error: invalid endpoint / proc doesn't exist */
+ return errno;
+ }
+
+ /* copy to old structure */
+ cred_old.pid = cred.pid;
+ cred_old.uid = (short) cred.uid;
+ cred_old.gid = (char) cred.gid;
+
+ rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
+ (vir_bytes) 0, (vir_bytes) &cred_old, sizeof(struct ucred_old),
+ D);
+
+ return rc ? EIO : OK;
+}
+
int do_getsockopt_sndbuf(message *dev_m_in, message *dev_m_out)
{
int minor;
/* Do not change uid/gid if new uid/gid is -1. */
uid = (m_in.owner == (uid_t)-1 ? vp->v_uid : m_in.owner);
gid = (m_in.group == (gid_t)-1 ? vp->v_gid : m_in.group);
- if ((r = req_chown(vp->v_fs_e, vp->v_inode_nr, uid, gid,
- &new_mode)) == OK) {
+
+ if (uid > UID_MAX || gid > GID_MAX)
+ r = EINVAL;
+ else if ((r = req_chown(vp->v_fs_e, vp->v_inode_nr, uid, gid,
+ &new_mode)) == OK) {
vp->v_uid = uid;
vp->v_gid = gid;
vp->v_mode = new_mode;
return(r);
}
-
/*===========================================================================*
* do_umask *
*===========================================================================*/
op = (rw_flag == READING ? MFS_DEV_READ : MFS_DEV_WRITE);
r = block_dev_io(op, dev, SELF_E, bp->b_data, pos, fs_block_size);
if (r < 0) {
- printf("MFS(%d) I/O error on device %d/%d, block %lu\n",
+ printf("MFS(%d) I/O error on device %d/%d, block %u\n",
SELF_E, major(dev), minor(dev), bp->b_blocknr);
op_failed = 1;
} else if( (unsigned) r != fs_block_size) {
/* Transfer failed. An error? Do we care? */
if (r != OK && i == 0) {
printf(
- "MFS: I/O error on device %d/%d, block %lu\n",
+ "MFS: I/O error on device %d/%d, block %u\n",
major(dev), minor(dev), bp->b_blocknr);
bp->b_dev = NO_DEV; /* invalidate block */
vm_forgetblocks();
#include <sys/queue.h>
EXTERN struct inode {
- mode_t i_mode; /* file type, protection, etc. */
- nlink_t i_nlinks; /* how many links to this file */
- uid_t i_uid; /* user id of the file's owner */
- gid_t i_gid; /* group number */
- off_t i_size; /* current file size in bytes */
- time_t i_atime; /* time of last access (V2 only) */
- time_t i_mtime; /* when was file data last changed */
- time_t i_ctime; /* when was inode itself changed (V2 only)*/
- zone_t i_zone[V2_NR_TZONES]; /* zone numbers for direct, ind, and dbl ind */
+ u16_t i_mode; /* file type, protection, etc. */
+ u16_t i_nlinks; /* how many links to this file */
+ u16_t i_uid; /* user id of the file's owner */
+ u16_t i_gid; /* group number */
+ i32_t i_size; /* current file size in bytes */
+ u32_t i_atime; /* time of last access (V2 only) */
+ u32_t i_mtime; /* when was file data last changed */
+ u32_t i_ctime; /* when was inode itself changed (V2 only)*/
+ u32_t i_zone[V2_NR_TZONES]; /* zone numbers for direct, ind, and dbl ind */
/* The following items are not present on the disk. */
dev_t i_dev; /* which device is the inode on */
read_ahead(); /* do block read ahead */
}
+
+ return(OK);
}
/*===========================================================================*
prevst.st_dev = st->st_dev;
prevst.st_ino = st->st_ino;
prevst.st_mode = st->st_mode;
- prevst.st_uid = st->st_uid;
- prevst.st_gid = st->st_gid;
+ prevst.st_uid = (short) st->st_uid;
+ prevst.st_gid = (short) st->st_gid;
prevst.st_size = st->st_size;
prevst.st_rdev = st->st_rdev;
statbuf.st_mode = rip->i_mode;
statbuf.st_nlink = rip->i_nlinks;
statbuf.st_uid = rip->i_uid;
- statbuf.st_gid = (short) rip->i_gid; /* FIXME: should become gid_t */
+ statbuf.st_gid = rip->i_gid;
statbuf.st_rdev = (s ? (dev_t) rip->i_zone[0] : NO_DEV);
statbuf.st_size = rip->i_size;
statbuf.st_atime = rip->i_atime;
scale = sp->s_log_zone_size;
- blockstats(&st.f_blocks, &st.f_bfree, &used);
+ blockstats((u32_t *) &st.f_blocks, (u32_t *) &st.f_bfree, &used);
st.f_bavail = st.f_bfree;
st.f_bsize = sp->s_block_size << scale;
break;
+ case NWIOGUDSPEERCREDOLD:
+
+ /* get peer endpoint -- getsockopt(SO_PEERCRED) */
+ rc = do_getsockopt_peercred_old(dev_m_in, dev_m_out);
+
+ break;
+
case NWIOSUDSTADDR:
/* set target address -- sendto() */
(message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_getsockopt_peercred,
(message *dev_m_in, message *dev_m_out) );
+_PROTOTYPE( int do_getsockopt_peercred_old,
+ (message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_getsockopt_sndbuf,
(message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_setsockopt_sndbuf,
return rc ? EIO : OK;
}
+PUBLIC int do_getsockopt_peercred_old(message *dev_m_in, message *dev_m_out)
+{
+ int minor;
+ int peer_minor;
+ int rc;
+ struct ucred cred;
+ struct ucred_old cred_old;
+
+#if DEBUG == 1
+ static int call_count = 0;
+ printf("(uds) [%d] do_getsockopt_peercred() call_count=%d\n",
+ uds_minor(dev_m_in), ++call_count);
+#endif
+
+ minor = uds_minor(dev_m_in);
+
+ if (uds_fd_table[minor].peer == -1) {
+
+ if (uds_fd_table[minor].err == ECONNRESET) {
+ uds_fd_table[minor].err = 0;
+
+ return ECONNRESET;
+ } else {
+ return ENOTCONN;
+ }
+ }
+
+ peer_minor = uds_fd_table[minor].peer;
+
+ /* obtain the peer's credentials */
+ rc = getnucred(uds_fd_table[peer_minor].owner, &cred);
+ if (rc == -1) {
+ /* likely error: invalid endpoint / proc doesn't exist */
+ return errno;
+ }
+
+ /* copy to old structure */
+ cred_old.pid = cred.pid;
+ cred_old.uid = (short) cred.uid;
+ cred_old.gid = (char) cred.gid;
+
+ rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
+ (vir_bytes) 0, (vir_bytes) &cred_old, sizeof(struct ucred_old),
+ D);
+
+ return rc ? EIO : OK;
+}
+
int do_getsockopt_sndbuf(message *dev_m_in, message *dev_m_out)
{
int minor;
*===========================================================================*/
PUBLIC int do_get()
{
-/* Handle GETUID, GETGID, GETPID, GETPGRP, GETSID.
+/* Handle GETUID, GETGID, GETGROUPS, GETGROUPS_O, GETPID, GETPGRP, GETSID.
*/
register struct mproc *rmp = mp;
- int r;
+ int r, i;
int ngroups;
+ char sgroups[NGROUPS_MAX]; /* XXX: Temp storage for GETGROUPS_O */
switch(call_nr) {
- case GETGROUPS:
- ngroups = m_in.grp_no;
- if (ngroups > NGROUPS_MAX || ngroups < 0)
- return(EINVAL);
+ case GETGROUPS_O:
+ ngroups = m_in.grp_no;
+ if (ngroups > NGROUPS_MAX || ngroups < 0)
+ return(EINVAL);
- if (ngroups == 0) {
- r = rmp->mp_ngroups;
- break;
- }
+ if (ngroups == 0) {
+ r = rmp->mp_ngroups;
+ break;
+ }
- if (ngroups < rmp->mp_ngroups)
+ if (ngroups < rmp->mp_ngroups)
/* Asking for less groups than available */
return(EINVAL);
+ for (i = 0; i < ngroups; i++)
+ sgroups[i] = (char) rmp->mp_sgroups[i];
+
+ r = sys_datacopy(SELF, (vir_bytes) &sgroups, who_e,
+ (vir_bytes) m_in.groupsp, ngroups * sizeof(char));
+
+ if (r != OK)
+ return(r);
+
+ r = rmp->mp_ngroups;
+ break;
+ case GETGROUPS:
+ ngroups = m_in.grp_no;
+ if (ngroups > NGROUPS_MAX || ngroups < 0)
+ return(EINVAL);
- r = sys_datacopy(SELF, (vir_bytes) rmp->mp_sgroups, who_e,
- (vir_bytes) m_in.groupsp, ngroups * sizeof(gid_t));
+ if (ngroups == 0) {
+ r = rmp->mp_ngroups;
+ break;
+ }
- if (r != OK)
- return(r);
-
- r = rmp->mp_ngroups;
- break;
+ if (ngroups < rmp->mp_ngroups)
+ /* Asking for less groups than available */
+ return(EINVAL);
+
+ r = sys_datacopy(SELF, (vir_bytes) rmp->mp_sgroups, who_e,
+ (vir_bytes) m_in.groupsp, ngroups * sizeof(gid_t));
+
+ if (r != OK)
+ return(r);
+
+ r = rmp->mp_ngroups;
+ break;
case GETUID:
r = rmp->mp_realuid;
rmp->mp_reply.reply_res2 = rmp->mp_effuid;
message m;
int r, i;
int ngroups;
+ char sgroups[NGROUPS_MAX]; /* XXX: Temp storage for SETGROUPS_O */
+
switch(call_nr) {
case SETUID:
if (r != OK)
return(r);
+ for (i = 0; i < ngroups; i++) {
+ if (rmp->mp_sgroups[i] > GID_MAX)
+ return(EINVAL);
+ }
+ for (i = ngroups; i < NGROUPS_MAX; i++) {
+ rmp->mp_sgroups[i] = 0;
+ }
+ rmp->mp_ngroups = ngroups;
+
+ m.m_type = PM_SETGROUPS;
+ m.PM_PROC = rmp->mp_endpoint;
+ m.PM_GROUP_NO = rmp->mp_ngroups;
+ m.PM_GROUP_ADDR = (char *) rmp->mp_sgroups;
+
+ break;
+ case SETGROUPS_O:
+ if (rmp->mp_effuid != SUPER_USER)
+ return(EPERM);
+
+ ngroups = m_in.grp_no;
+
+ if (ngroups > NGROUPS_MAX || ngroups < 0)
+ return(EINVAL);
+
+ if (m_in.groupsp == NULL)
+ return(EFAULT);
+
+ r = sys_datacopy(who_e, (vir_bytes) m_in.groupsp, SELF,
+ (vir_bytes) &sgroups, ngroups * sizeof(char));
+ if (r != OK)
+ return(r);
+
+ for (i = 0; i < ngroups; i++)
+ rmp->mp_sgroups[i] = (gid_t) sgroups[i];
for (i = ngroups; i < NGROUPS_MAX; i++)
rmp->mp_sgroups[i] = 0;
rmp->mp_ngroups = ngroups;
m.m_type = PM_SETGROUPS;
m.PM_PROC = rmp->mp_endpoint;
m.PM_GROUP_NO = rmp->mp_ngroups;
- m.PM_GROUP_ADDR = rmp->mp_sgroups;
+ m.PM_GROUP_ADDR = (char *) rmp->mp_sgroups;
break;
case SETSID:
endpoint_t ep;
/* This call should be moved to DS. */
- if (mp->mp_effuid != 0)
- {
- printf("PM: unauthorized call of do_getepinfo by proc %d\n",
+ if (mp->mp_effuid != 0) {
+ printf("PM: unauthorized call of do_getepinfo_o by proc %d\n",
mp->mp_endpoint);
sys_sysctl_stacktrace(mp->mp_endpoint);
return EPERM;
}
- ep= m_in.PM_ENDPT;
+ ep = m_in.PM_ENDPT;
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
if ((rmp->mp_flags & IN_USE) && (rmp->mp_endpoint == ep)) {
mp->mp_reply.reply_res3 = rmp->mp_effgid;
return(rmp->mp_pid);
}
- }
+ }
+
+ /* Process not found */
+ return(ESRCH);
+}
+
+/*===========================================================================*
+ * do_getepinfo_o *
+ *===========================================================================*/
+PUBLIC int do_getepinfo_o()
+{
+ register struct mproc *rmp;
+ endpoint_t ep;
+
+ /* This call should be moved to DS. */
+ if (mp->mp_effuid != 0) {
+ printf("PM: unauthorized call of do_getepinfo_o by proc %d\n",
+ mp->mp_endpoint);
+ sys_sysctl_stacktrace(mp->mp_endpoint);
+ return EPERM;
+ }
+
+ ep = m_in.PM_ENDPT;
+
+ for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
+ if ((rmp->mp_flags & IN_USE) && (rmp->mp_endpoint == ep)) {
+ mp->mp_reply.reply_res2 = (short) rmp->mp_effuid;
+ mp->mp_reply.reply_res3 = (char) rmp->mp_effgid;
+ return(rmp->mp_pid);
+ }
+ }
/* Process not found */
return(ESRCH);
_PROTOTYPE( int do_getsysinfo_up, (void) );
_PROTOTYPE( int do_getprocnr, (void) );
_PROTOTYPE( int do_getepinfo, (void) );
+_PROTOTYPE( int do_getepinfo_o, (void) );
_PROTOTYPE( int do_svrctl, (void) );
_PROTOTYPE( int do_getsetpriority, (void) );
do_exit, /* 1 = exit */
do_fork, /* 2 = fork */
no_sys, /* 3 = read */
- no_sys, /* 4 = write */
+ no_sys, /* 4 = write */
no_sys, /* 5 = open */
no_sys, /* 6 = close */
do_waitpid, /* 7 = wait */
no_sys, /* 28 = fstat */
do_pause, /* 29 = pause */
no_sys, /* 30 = utime */
- no_sys, /* 31 = (stty) */
- no_sys, /* 32 = (gtty) */
+ do_getepinfo, /* 31 = getepinfo */
+ do_set, /* 32 = setgroups */
no_sys, /* 33 = access */
- no_sys, /* 34 = (nice) */
- no_sys, /* 35 = (ftime) */
+ do_get, /* 34 = getgroups */
+ no_sys, /* 35 = unused */
no_sys, /* 36 = sync */
do_kill, /* 37 = kill */
no_sys, /* 38 = rename */
no_sys, /* 41 = dup */
no_sys, /* 42 = pipe */
do_times, /* 43 = times */
- no_sys, /* 44 = (prof) */
+ no_sys, /* 44 = unused */
no_sys, /* 45 = unused */
do_set, /* 46 = setgid */
do_get, /* 47 = getgid */
no_sys, /* 48 = (signal)*/
no_sys, /* 49 = unused */
no_sys, /* 50 = lstat */
- no_sys, /* 51 = (acct) */
- no_sys, /* 52 = (phys) */
- no_sys, /* 53 = (lock) */
+ no_sys, /* 51 = unused */
+ no_sys, /* 52 = unused */
+ no_sys, /* 53 = unused */
no_sys, /* 54 = ioctl */
no_sys, /* 55 = fcntl */
- no_sys, /* 56 = (mpx) */
+ no_sys, /* 56 = unused */
no_sys, /* 57 = unused */
no_sys, /* 58 = unused */
do_exec, /* 59 = execve */
do_getprocnr, /* 104 = getprocnr */
no_sys, /* 105 = unused */
no_sys, /* 106 = unused */
- do_getepinfo, /* 107 = getepinfo */
+ do_getepinfo_o, /* 107 = getepinfo XXX: old implementation*/
do_adddma, /* 108 = adddma */
do_deldma, /* 109 = deldma */
do_getdma, /* 110 = getdma */
break;
case PM_SETGROUPS:
- pm_setgroups(m_in.PM_PROC, m_in.PM_GROUP_NO, m_in.PM_GROUP_ADDR);
+ pm_setgroups(m_in.PM_PROC, m_in.PM_GROUP_NO, (gid_t *) m_in.PM_GROUP_ADDR);
m_out.m_type = PM_SETGROUPS_REPLY;
m_out.PM_PROC = m_in.PM_PROC;
}
if (r == OK) {
- /* Do not change uid/gid if new uid/gid is -1. */
- uid = (m_in.owner == (uid_t)-1 ? vp->v_uid : m_in.owner);
- gid = (m_in.group == (gid_t)-1 ? vp->v_gid : m_in.group);
- if ((r = req_chown(vp->v_fs_e, vp->v_inode_nr, uid, gid,
- &new_mode)) == OK) {
+ /* Do not change uid/gid if new uid/gid is -1. */
+ uid = (m_in.owner == (uid_t)-1 ? vp->v_uid : m_in.owner);
+ gid = (m_in.group == (gid_t)-1 ? vp->v_gid : m_in.group);
+
+ if (uid > UID_MAX || gid > GID_MAX)
+ r = EINVAL;
+ else if ((r = req_chown(vp->v_fs_e, vp->v_inode_nr, uid, gid,
+ &new_mode)) == OK) {
vp->v_uid = uid;
vp->v_gid = gid;
vp->v_mode = new_mode;
do_fstat, /* 28 = fstat (prev)*/
no_sys, /* 29 = pause */
do_utime, /* 30 = utime */
- no_sys, /* 31 = (stty) */
- no_sys, /* 32 = (gtty) */
+ no_sys, /* 31 = unused */
+ no_sys, /* 32 = unused */
do_access, /* 33 = access */
- no_sys, /* 34 = (nice) */
- no_sys, /* 35 = (ftime) */
+ no_sys, /* 34 = unused */
+ no_sys, /* 35 = unused */
do_sync, /* 36 = sync */
no_sys, /* 37 = kill */
do_rename, /* 38 = rename */
do_dup, /* 41 = dup */
do_pipe, /* 42 = pipe */
no_sys, /* 43 = times */
- no_sys, /* 44 = (prof) */
+ no_sys, /* 44 = unused */
do_slink, /* 45 = symlink */
no_sys, /* 46 = (setgid)*/
no_sys, /* 47 = getgid */
no_sys, /* 48 = (signal)*/
do_rdlink, /* 49 = readlink*/
do_lstat, /* 50 = lstat (prev)*/
- no_sys, /* 51 = (acct) */
- no_sys, /* 52 = (phys) */
- no_sys, /* 53 = (lock) */
+ no_sys, /* 51 = unused */
+ no_sys, /* 52 = unused */
+ no_sys, /* 53 = unused */
do_ioctl, /* 54 = ioctl */
do_fcntl, /* 55 = fcntl */
- no_sys, /* 56 = (mpx) */
+ no_sys, /* 56 = unused */
do_fslogin, /* 57 = FS proc login */
no_sys, /* 58 = unused */
no_sys, /* 59 = (execve)*/
_PROTOTYPE( void group_test_5, (void) );
_PROTOTYPE( int dotest, (void (*testfunc)(void)) );
-int subtest = -1, errorct = 0;
-#define ERROR_MAX 5
+#define MAX_ERROR 5
#define IMAGINARY_GID 100
#define IMAGINARY_GID_STR "100"
#define IMAGINARY_UID 101
setgid((IMAGINARY_GID) + 1 ); \
setuid(IMAGINARY_UID); \
} while(0)
+#include "common.c"
+
+int subtest = -1, errorct = 0;
int main(int argc, char *argv[])
{
int superuser;
- printf("Test 46 ");
- fflush(stdout);
+ start(46);
superuser = (geteuid() == 0);
api_test(); /* Perform some very basic API tests */
group_test(); /* Perform some tests that mimic actual use */
- if(errorct > 0) {
- printf("%d error(s)\n", errorct);
- return(errorct);
- }
-
- printf("ok\n");
- return(0);
+ quit();
}
void limit_test() {
/* Let's invent some imaginary groups */
#define START_GID 20001
- for (i = START_GID; i < START_GID + ngroups_max; i++)
- grouplist[i - START_GID] = i;
+ for (i = 0; i < ngroups_max; i++)
+ grouplist[i] = i + START_GID;
/* Normal usage */
if (setgroups(ngroups_max, grouplist) != 0) e(1);
}
}
+ /* Try to set too high a group ID */
+ grouplist2[0] = GID_MAX + 1; /* Out of range */
+ if (setgroups(1, grouplist2) == 0) e(23);
+ if (errno != EINVAL) e(24);
+
free(grouplist);
free(grouplist2);
}
dirp = opendir("DIR_046/sub");
exit(dirp != NULL); /* If not NULL, we were able to access it */
}
-
-void e(int error_no) {
- printf("Subtest %d, error %d\n", subtest, error_no);
-
- if (errorct++ > ERROR_MAX) {
- printf("Too many errors, test aborted\n");
- exit(1);
- }
-}
-