projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't clear set-gid when su creates file when not groupmember
[unix-history]
/
usr
/
src
/
sys
/
ufs
/
lfs
/
lfs_vnops.c
diff --git
a/usr/src/sys/ufs/lfs/lfs_vnops.c
b/usr/src/sys/ufs/lfs/lfs_vnops.c
index
47ab6b6
..
6073578
100644
(file)
--- a/
usr/src/sys/ufs/lfs/lfs_vnops.c
+++ b/
usr/src/sys/ufs/lfs/lfs_vnops.c
@@
-1,9
+1,9
@@
/*
/*
- * Copyright (c) 1982 Regents of the University of California.
+ * Copyright (c) 1982
, 1986
Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)lfs_vnops.c
6.21
(Berkeley) %G%
+ * @(#)lfs_vnops.c
7.3
(Berkeley) %G%
*/
#include "param.h"
*/
#include "param.h"
@@
-119,14
+119,12
@@
copen(mode, arg, fname)
register struct inode *ip;
register struct file *fp;
register struct nameidata *ndp = &u.u_nd;
register struct inode *ip;
register struct file *fp;
register struct nameidata *ndp = &u.u_nd;
- int i;
+ int i
ndx
;
-#ifdef notdef
- if ((mode&(FREAD|FWRITE)) == 0) {
- u.u_error = EINVAL;
+ fp = falloc();
+ if (fp == NULL)
return;
return;
- }
-#endif
+ indx = u.u_r.r_val1;
ndp->ni_segflg = UIO_USERSPACE;
ndp->ni_dirp = fname;
if (mode&FCREAT) {
ndp->ni_segflg = UIO_USERSPACE;
ndp->ni_dirp = fname;
if (mode&FCREAT) {
@@
-137,16
+135,15
@@
copen(mode, arg, fname)
ip = namei(ndp);
if (ip == NULL) {
if (u.u_error)
ip = namei(ndp);
if (ip == NULL) {
if (u.u_error)
-
return
;
+
goto bad1
;
ip = maknode(arg&07777&(~ISVTX), ndp);
if (ip == NULL)
ip = maknode(arg&07777&(~ISVTX), ndp);
if (ip == NULL)
-
return
;
+
goto bad1
;
mode &= ~FTRUNC;
} else {
if (mode&FEXCL) {
u.u_error = EEXIST;
mode &= ~FTRUNC;
} else {
if (mode&FEXCL) {
u.u_error = EEXIST;
- iput(ip);
- return;
+ goto bad;
}
mode &= ~FCREAT;
}
}
mode &= ~FCREAT;
}
@@
-154,7
+151,7
@@
copen(mode, arg, fname)
ndp->ni_nameiop = LOOKUP | FOLLOW;
ip = namei(ndp);
if (ip == NULL)
ndp->ni_nameiop = LOOKUP | FOLLOW;
ip = namei(ndp);
if (ip == NULL)
-
return
;
+
goto bad1
;
}
if ((ip->i_mode & IFMT) == IFSOCK) {
u.u_error = EOPNOTSUPP;
}
if ((ip->i_mode & IFMT) == IFSOCK) {
u.u_error = EOPNOTSUPP;
@@
-173,9
+170,6
@@
copen(mode, arg, fname)
}
}
}
}
}
}
- fp = falloc();
- if (fp == NULL)
- goto bad;
if (mode&FTRUNC)
itrunc(ip, (u_long)0);
IUNLOCK(ip);
if (mode&FTRUNC)
itrunc(ip, (u_long)0);
IUNLOCK(ip);
@@
-183,23
+177,22
@@
copen(mode, arg, fname)
fp->f_type = DTYPE_INODE;
fp->f_ops = &inodeops;
fp->f_data = (caddr_t)ip;
fp->f_type = DTYPE_INODE;
fp->f_ops = &inodeops;
fp->f_data = (caddr_t)ip;
- i = u.u_r.r_val1;
if (setjmp(&u.u_qsave)) {
if (u.u_error == 0)
u.u_error = EINTR;
if (setjmp(&u.u_qsave)) {
if (u.u_error == 0)
u.u_error = EINTR;
- u.u_ofile[i] = NULL;
+ u.u_ofile[i
ndx
] = NULL;
closef(fp);
return;
}
u.u_error = openi(ip, mode);
if (u.u_error == 0)
return;
closef(fp);
return;
}
u.u_error = openi(ip, mode);
if (u.u_error == 0)
return;
- u.u_ofile[i] = NULL;
- fp->f_count--;
- irele(ip);
- return;
+ ILOCK(ip);
bad:
iput(ip);
bad:
iput(ip);
+bad1:
+ u.u_ofile[indx] = NULL;
+ fp->f_count--;
}
/*
}
/*
@@
-338,7
+331,8
@@
symlink()
ip = maknode(IFLNK | 0777, ndp);
if (ip == NULL)
return;
ip = maknode(IFLNK | 0777, ndp);
if (ip == NULL)
return;
- u.u_error = rdwri(UIO_WRITE, ip, uap->target, nc, 0, 0, (int *)0);
+ u.u_error = rdwri(UIO_WRITE, ip, uap->target, nc, (off_t)0, 0,
+ (int *)0);
/* handle u.u_error != 0 */
iput(ip);
}
/* handle u.u_error != 0 */
iput(ip);
}
@@
-523,7
+517,8
@@
readlink()
u.u_error = EINVAL;
goto out;
}
u.u_error = EINVAL;
goto out;
}
- u.u_error = rdwri(UIO_READ, ip, uap->buf, uap->count, 0, 0, &resid);
+ u.u_error = rdwri(UIO_READ, ip, uap->buf, uap->count, (off_t)0, 0,
+ &resid);
out:
iput(ip);
u.u_r.r_val1 = uap->count - resid;
out:
iput(ip);
u.u_r.r_val1 = uap->count - resid;
@@
-606,7
+601,7
@@
chown()
int gid;
} *uap = (struct a *)u.u_ap;
int gid;
} *uap = (struct a *)u.u_ap;
- if (
!suser() ||
(ip = owner(uap->fname, NOFOLLOW)) == NULL)
+ if ((ip = owner(uap->fname, NOFOLLOW)) == NULL)
return;
u.u_error = chown1(ip, uap->uid, uap->gid);
iput(ip);
return;
u.u_error = chown1(ip, uap->uid, uap->gid);
iput(ip);
@@
-629,8
+624,6
@@
fchown()
if (fp == NULL)
return;
ip = (struct inode *)fp->f_data;
if (fp == NULL)
return;
ip = (struct inode *)fp->f_data;
- if (!suser())
- return;
ILOCK(ip);
u.u_error = chown1(ip, uap->uid, uap->gid);
IUNLOCK(ip);
ILOCK(ip);
u.u_error = chown1(ip, uap->uid, uap->gid);
IUNLOCK(ip);
@@
-654,6
+647,10
@@
chown1(ip, uid, gid)
uid = ip->i_uid;
if (gid == -1)
gid = ip->i_gid;
uid = ip->i_uid;
if (gid == -1)
gid = ip->i_gid;
+ if (uid != ip->i_uid && !suser())
+ return (u.u_error);
+ if (gid != ip->i_gid && !groupmember((gid_t)gid) && !suser())
+ return (u.u_error);
#ifdef QUOTA
if (ip->i_uid == uid) /* this just speeds things a little */
change = 0;
#ifdef QUOTA
if (ip->i_uid == uid) /* this just speeds things a little */
change = 0;
@@
-671,7
+668,7
@@
chown1(ip, uid, gid)
#ifdef QUOTA
ip->i_dquot = inoquota(ip);
(void) chkdq(ip, change, 1);
#ifdef QUOTA
ip->i_dquot = inoquota(ip);
(void) chkdq(ip, change, 1);
- (void) chkiq(ip->i_dev, (struct inode *)NULL, uid, 1);
+ (void) chkiq(ip->i_dev, (struct inode *)NULL,
(uid_t)
uid, 1);
return (u.u_error); /* should == 0 ALWAYS !! */
#else
return (0);
return (u.u_error); /* should == 0 ALWAYS !! */
#else
return (0);
@@
-718,7
+715,7
@@
truncate()
{
struct a {
char *fname;
{
struct a {
char *fname;
-
u_long
length;
+
off_t
length;
} *uap = (struct a *)u.u_ap;
struct inode *ip;
register struct nameidata *ndp = &u.u_nd;
} *uap = (struct a *)u.u_ap;
struct inode *ip;
register struct nameidata *ndp = &u.u_nd;
@@
-735,7
+732,7
@@
truncate()
u.u_error = EISDIR;
goto bad;
}
u.u_error = EISDIR;
goto bad;
}
- itrunc(ip, uap->length);
+ itrunc(ip,
(u_long)
uap->length);
bad:
iput(ip);
}
bad:
iput(ip);
}
@@
-747,7
+744,7
@@
ftruncate()
{
struct a {
int fd;
{
struct a {
int fd;
-
u_long
length;
+
off_t
length;
} *uap = (struct a *)u.u_ap;
struct inode *ip;
struct file *fp;
} *uap = (struct a *)u.u_ap;
struct inode *ip;
struct file *fp;
@@
-761,7
+758,7
@@
ftruncate()
}
ip = (struct inode *)fp->f_data;
ILOCK(ip);
}
ip = (struct inode *)fp->f_data;
ILOCK(ip);
- itrunc(ip, uap->length);
+ itrunc(ip,
(u_long)
uap->length);
IUNLOCK(ip);
}
IUNLOCK(ip);
}
@@
-781,6
+778,8
@@
fsync()
return;
ip = (struct inode *)fp->f_data;
ILOCK(ip);
return;
ip = (struct inode *)fp->f_data;
ILOCK(ip);
+ if (fp->f_flag&FWRITE)
+ ip->i_flag |= ICHG;
syncip(ip);
IUNLOCK(ip);
}
syncip(ip);
IUNLOCK(ip);
}
@@
-1114,7
+1113,7
@@
maknode(mode, ndp)
ip->i_nlink = 1;
ip->i_uid = u.u_uid;
ip->i_gid = pdir->i_gid;
ip->i_nlink = 1;
ip->i_uid = u.u_uid;
ip->i_gid = pdir->i_gid;
- if (ip->i_mode & ISGID && !groupmember(ip->i_gid))
+ if (ip->i_mode & ISGID && !groupmember(ip->i_gid)
&& !suser()
)
ip->i_mode &= ~ISGID;
#ifdef QUOTA
ip->i_dquot = inoquota(ip);
ip->i_mode &= ~ISGID;
#ifdef QUOTA
ip->i_dquot = inoquota(ip);