don't use setreuid(2) etc. stuff, like OpenBSD
only affects suid shell scripts, which are *ugh* anyway, and I really have no idea what the old code did, when, why, etc. 262t 16d 2i
This commit is contained in:
parent
27443bc0c8
commit
2342fa1242
6
exec.c
6
exec.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.18 2006/11/10 04:03:58 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.19 2006/11/10 06:16:24 tg Exp $");
|
||||||
|
|
||||||
static int comexec(struct op *, struct tbl *volatile, char **,
|
static int comexec(struct op *, struct tbl *volatile, char **,
|
||||||
int volatile);
|
int volatile);
|
||||||
@ -833,7 +833,7 @@ findcom(const char *name, int flags)
|
|||||||
tp = tbi;
|
tp = tbi;
|
||||||
if (!tp && (flags & FC_PATH) && !(flags & FC_DEFPATH)) {
|
if (!tp && (flags & FC_PATH) && !(flags & FC_DEFPATH)) {
|
||||||
tp = ktsearch(&taliases, name, h);
|
tp = ktsearch(&taliases, name, h);
|
||||||
if (tp && (tp->flag & ISSET) && eaccess(tp->val.s, X_OK) != 0) {
|
if (tp && (tp->flag & ISSET) && access(tp->val.s, X_OK) != 0) {
|
||||||
if (tp->flag & ALLOC) {
|
if (tp->flag & ALLOC) {
|
||||||
tp->flag &= ~ALLOC;
|
tp->flag &= ~ALLOC;
|
||||||
afree(tp->val.s, APERM);
|
afree(tp->val.s, APERM);
|
||||||
@ -907,7 +907,7 @@ search_access(const char *lpath, int mode,
|
|||||||
|
|
||||||
if (stat(lpath, &statb) < 0)
|
if (stat(lpath, &statb) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
ret = eaccess(lpath, mode);
|
ret = access(lpath, mode);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
err = errno; /* File exists, but we can't access it */
|
err = errno; /* File exists, but we can't access it */
|
||||||
else if (mode == X_OK && (!S_ISREG(statb.st_mode) ||
|
else if (mode == X_OK && (!S_ISREG(statb.st_mode) ||
|
||||||
|
6
funcs.c
6
funcs.c
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.33 2006/11/10 03:45:56 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.34 2006/11/10 06:16:24 tg Exp $");
|
||||||
|
|
||||||
int
|
int
|
||||||
c_cd(char **wp)
|
c_cd(char **wp)
|
||||||
@ -176,7 +176,7 @@ c_pwd(char **wp)
|
|||||||
}
|
}
|
||||||
p = current_wd[0] ? (physical ? get_phys_path(current_wd) : current_wd) :
|
p = current_wd[0] ? (physical ? get_phys_path(current_wd) : current_wd) :
|
||||||
NULL;
|
NULL;
|
||||||
if (p && eaccess(p, R_OK) < 0)
|
if (p && access(p, R_OK) < 0)
|
||||||
p = NULL;
|
p = NULL;
|
||||||
if (!p && !(p = ksh_get_wd(NULL))) {
|
if (!p && !(p = ksh_get_wd(NULL))) {
|
||||||
bi_errorf("can't get current directory - %s", strerror(errno));
|
bi_errorf("can't get current directory - %s", strerror(errno));
|
||||||
@ -2655,7 +2655,7 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
|
|||||||
static int
|
static int
|
||||||
test_eaccess(const char *pathl, int mode)
|
test_eaccess(const char *pathl, int mode)
|
||||||
{
|
{
|
||||||
int res = eaccess(pathl, mode);
|
int res = access(pathl, mode);
|
||||||
|
|
||||||
if (res == 0 && ksheuid == 0 && (mode & X_OK)) {
|
if (res == 0 && ksheuid == 0 && (mode & X_OK)) {
|
||||||
struct stat statb;
|
struct stat statb;
|
||||||
|
3
sh.h
3
sh.h
@ -8,7 +8,7 @@
|
|||||||
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
||||||
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
||||||
|
|
||||||
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.74 2006/11/10 05:23:13 tg Exp $"
|
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.75 2006/11/10 06:16:25 tg Exp $"
|
||||||
#define MKSH_VERSION "R29 2006/11/10"
|
#define MKSH_VERSION "R29 2006/11/10"
|
||||||
|
|
||||||
#if HAVE_SYS_PARAM_H
|
#if HAVE_SYS_PARAM_H
|
||||||
@ -1310,7 +1310,6 @@ void change_random(void);
|
|||||||
int array_ref_len(const char *);
|
int array_ref_len(const char *);
|
||||||
char *arrayname(const char *);
|
char *arrayname(const char *);
|
||||||
void set_array(const char *, int, char **);
|
void set_array(const char *, int, char **);
|
||||||
int eaccess(const char *, int);
|
|
||||||
|
|
||||||
enum Test_op {
|
enum Test_op {
|
||||||
TO_NONOP = 0, /* non-operator */
|
TO_NONOP = 0, /* non-operator */
|
||||||
|
27
var.c
27
var.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.26 2006/11/10 05:23:14 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.27 2006/11/10 06:16:25 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables
|
* Variables
|
||||||
@ -983,7 +983,7 @@ setspec(struct tbl *vp)
|
|||||||
struct stat statb;
|
struct stat statb;
|
||||||
|
|
||||||
s = str_val(vp);
|
s = str_val(vp);
|
||||||
if (s[0] == '/' && eaccess(s, W_OK|X_OK) == 0 &&
|
if (s[0] == '/' && access(s, W_OK|X_OK) == 0 &&
|
||||||
stat(s, &statb) == 0 && S_ISDIR(statb.st_mode))
|
stat(s, &statb) == 0 && S_ISDIR(statb.st_mode))
|
||||||
tmpdir = str_save(s, APERM);
|
tmpdir = str_save(s, APERM);
|
||||||
}
|
}
|
||||||
@ -1180,26 +1180,3 @@ set_array(const char *var, int reset, char **vals)
|
|||||||
setstr(vq, vals[i], KSH_RETURN_ERROR);
|
setstr(vq, vals[i], KSH_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
eaccess(const char *pathname, int mode)
|
|
||||||
{
|
|
||||||
bool need_uid, need_gid;
|
|
||||||
int rv, _errno;
|
|
||||||
|
|
||||||
if ((need_gid = (kshgid != kshegid)))
|
|
||||||
setregid(kshegid, kshgid);
|
|
||||||
if ((need_uid = (kshuid != ksheuid)))
|
|
||||||
setreuid(ksheuid, kshuid);
|
|
||||||
|
|
||||||
rv = access(pathname, mode);
|
|
||||||
_errno = errno;
|
|
||||||
|
|
||||||
if (need_gid)
|
|
||||||
setregid(kshgid, kshegid);
|
|
||||||
if (need_uid)
|
|
||||||
setreuid(kshuid, ksheuid);
|
|
||||||
|
|
||||||
errno = _errno;
|
|
||||||
return (rv);
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user