Browse Source

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  cron: respect PATH from login.conf
  bmake: fix -fno-common build
  gdb: compile with -fcommon explicitly
  evdev: return error rather than zero-length data on blocked read()
  evdev: Add COMPAT_FREEBSD32 support for amd64 arch
hardened/current/tmpfs_extattr
HardenedBSD Sync Service 2 months ago
parent
commit
ee2bba3dce
7 changed files with 157 additions and 47 deletions
  1. +2
    -0
      contrib/bmake/main.c
  2. +1
    -1
      contrib/bmake/make.h
  3. +5
    -0
      gnu/usr.bin/gdb/Makefile.inc
  4. +70
    -12
      sys/dev/evdev/cdev.c
  5. +54
    -5
      usr.sbin/cron/cron/do_command.c
  6. +18
    -17
      usr.sbin/cron/crontab/crontab.5
  7. +7
    -12
      usr.sbin/cron/lib/entry.c

+ 2
- 0
contrib/bmake/main.c View File

@@ -199,6 +199,8 @@ char *makeDependfile;
pid_t myPid;
int makelevel;

FILE *debug_file;

Boolean forceJobs = FALSE;

/*

+ 1
- 1
contrib/bmake/make.h View File

@@ -464,7 +464,7 @@ extern pid_t myPid;
* There is one bit per module. It is up to the module what debug
* information to print.
*/
FILE *debug_file; /* Output written here - default stdout */
extern FILE *debug_file; /* Output written here - default stdout */
extern int debug;
#define DEBUG_ARCH 0x00001
#define DEBUG_COND 0x00002

+ 5
- 0
gnu/usr.bin/gdb/Makefile.inc View File

@@ -47,6 +47,11 @@ CFLAGS+= -I${CNTRB_GDB}/include
CFLAGS+= -I${CNTRB_BU}/bfd
CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/edit

# Some bits here currently rely on some of the linker-merging magic that happens
# with -fcommon. While this is the default right now, explicitly set -fcommon
# so that it continues to build when the default flips.
CFLAGS+= -fcommon

GENSRCS+= nm.h tm.h

.if defined(GDB_CROSS_DEBUGGER)

+ 70
- 12
sys/dev/evdev/cdev.c View File

@@ -47,6 +47,18 @@
#include <dev/evdev/evdev_private.h>
#include <dev/evdev/input.h>

#ifdef COMPAT_FREEBSD32
#include <sys/mount.h>
#include <sys/sysent.h>
#include <compat/freebsd32/freebsd32.h>
struct input_event32 {
struct timeval32 time;
uint16_t type;
uint16_t code;
int32_t value;
};
#endif

#ifdef EVDEV_DEBUG
#define debugf(client, fmt, args...) printf("evdev cdev: "fmt"\n", ##args)
#else
@@ -161,7 +173,14 @@ static int
evdev_read(struct cdev *dev, struct uio *uio, int ioflag)
{
struct evdev_client *client;
struct input_event event;
union {
struct input_event t;
#ifdef COMPAT_FREEBSD32
struct input_event32 t32;
#endif
} event;
struct input_event *head;
size_t evsize;
int ret = 0;
int remaining;

@@ -175,11 +194,18 @@ evdev_read(struct cdev *dev, struct uio *uio, int ioflag)
if (client->ec_revoked)
return (ENODEV);

#ifdef COMPAT_FREEBSD32
if (SV_CURPROC_FLAG(SV_ILP32))
evsize = sizeof(struct input_event32);
else
#endif
evsize = sizeof(struct input_event);

/* Zero-sized reads are allowed for error checking */
if (uio->uio_resid != 0 && uio->uio_resid < sizeof(struct input_event))
if (uio->uio_resid != 0 && uio->uio_resid < evsize)
return (EINVAL);

remaining = uio->uio_resid / sizeof(struct input_event);
remaining = uio->uio_resid / evsize;

EVDEV_CLIENT_LOCKQ(client);

@@ -191,19 +217,31 @@ evdev_read(struct cdev *dev, struct uio *uio, int ioflag)
client->ec_blocked = true;
ret = mtx_sleep(client, &client->ec_buffer_mtx,
PCATCH, "evread", 0);
if (ret == 0 && client->ec_revoked)
ret = ENODEV;
}
}
}

while (ret == 0 && !EVDEV_CLIENT_EMPTYQ(client) && remaining > 0) {
memcpy(&event, &client->ec_buffer[client->ec_buffer_head],
sizeof(struct input_event));
head = client->ec_buffer + client->ec_buffer_head;
#ifdef COMPAT_FREEBSD32
if (SV_CURPROC_FLAG(SV_ILP32)) {
bzero(&event.t32, sizeof(struct input_event32));
TV_CP(*head, event.t32, time);
CP(*head, event.t32, type);
CP(*head, event.t32, code);
CP(*head, event.t32, value);
} else
#endif
bcopy(head, &event.t, evsize);

client->ec_buffer_head =
(client->ec_buffer_head + 1) % client->ec_buffer_size;
remaining--;

EVDEV_CLIENT_UNLOCKQ(client);
ret = uiomove(&event, sizeof(struct input_event), uio);
ret = uiomove(&event, evsize, uio);
EVDEV_CLIENT_LOCKQ(client);
}

@@ -217,7 +255,13 @@ evdev_write(struct cdev *dev, struct uio *uio, int ioflag)
{
struct evdev_dev *evdev = dev->si_drv1;
struct evdev_client *client;
struct input_event event;
union {
struct input_event t;
#ifdef COMPAT_FREEBSD32
struct input_event32 t32;
#endif
} event;
size_t evsize;
int ret = 0;

ret = devfs_get_cdevpriv((void **)&client);
@@ -230,16 +274,30 @@ evdev_write(struct cdev *dev, struct uio *uio, int ioflag)
if (client->ec_revoked || evdev == NULL)
return (ENODEV);

if (uio->uio_resid % sizeof(struct input_event) != 0) {
#ifdef COMPAT_FREEBSD32
if (SV_CURPROC_FLAG(SV_ILP32))
evsize = sizeof(struct input_event32);
else
#endif
evsize = sizeof(struct input_event);

if (uio->uio_resid % evsize != 0) {
debugf(client, "write size not multiple of input_event size");
return (EINVAL);
}

while (uio->uio_resid > 0 && ret == 0) {
ret = uiomove(&event, sizeof(struct input_event), uio);
if (ret == 0)
ret = evdev_inject_event(evdev, event.type, event.code,
event.value);
ret = uiomove(&event, evsize, uio);
if (ret == 0) {
#ifdef COMPAT_FREEBSD32
if (SV_CURPROC_FLAG(SV_ILP32))
ret = evdev_inject_event(evdev, event.t32.type,
event.t32.code, event.t32.value);
else
#endif
ret = evdev_inject_event(evdev, event.t.type,
event.t.code, event.t.value);
}
}

return (ret);

+ 54
- 5
usr.sbin/cron/cron/do_command.c View File

@@ -97,6 +97,7 @@ child_process(e, u)
register FILE *mail;
register int bytes = 1;
int status = 0;
const char *homedir = NULL;
# if defined(LOGIN_CAP)
struct passwd *pwd;
login_cap_t *lc;
@@ -287,6 +288,14 @@ child_process(e, u)
pwd = getpwuid(e->uid);
lc = NULL;
if (pwd != NULL) {
if (pwd->pw_dir != NULL
&& pwd->pw_dir[0] != '\0') {
homedir = strdup(pwd->pw_dir);
if (homedir == NULL) {
warn("strdup");
_exit(ERROR_EXIT);
}
}
pwd->pw_gid = e->gid;
if (e->class != NULL)
lc = login_getclass(e->class);
@@ -330,17 +339,38 @@ child_process(e, u)
if (lc != NULL)
login_close(lc);
#endif
chdir(env_get("HOME", e->envp));

/* exec the command.
/* For compatibility, we chdir to the value of HOME if it was
* specified explicitly in the crontab file, but not if it was
* set in the environment by some other mechanism. We chdir to
* the homedir given by the pw entry otherwise.
*
* If !LOGIN_CAP, then HOME is always set in e->envp.
*
* XXX: probably should also consult PAM.
*/
{
char *new_home = env_get("HOME", e->envp);
if (new_home != NULL && new_home[0] != '\0')
chdir(new_home);
else if (homedir != NULL)
chdir(homedir);
else
chdir("/");
}

/* exec the command. Note that SHELL is not respected from
* either login.conf or pw_shell, only an explicit setting
* in the crontab. (default of _PATH_BSHELL is supplied when
* setting up the entry)
*/
{
char *shell = env_get("SHELL", e->envp);
char **p;

/* Apply the environment from the entry, overriding existing
* values (this will always set PATH, LOGNAME, etc.) putenv
* should not fail unless malloc does.
/* Apply the environment from the entry, overriding
* existing values (this will always set LOGNAME and
* SHELL). putenv should not fail unless malloc does.
*/
for (p = e->envp; *p; ++p) {
if (putenv(*p) != 0) {
@@ -349,6 +379,25 @@ child_process(e, u)
}
}

/* HOME in login.conf overrides pw, and HOME in the
* crontab overrides both. So set pw's value only if
* nothing was already set (overwrite==0).
*/
if (homedir != NULL
&& setenv("HOME", homedir, 0) < 0) {
warn("setenv(HOME)");
_exit(ERROR_EXIT);
}

/* PATH in login.conf is respected, but the crontab
* overrides; set a default value only if nothing
* already set.
*/
if (setenv("PATH", _PATH_DEFPATH, 0) < 0) {
warn("setenv(PATH)");
_exit(ERROR_EXIT);
}

# if DEBUGGING
if (DebugFlags & DTEST) {
fprintf(stderr,

+ 18
- 17
usr.sbin/cron/crontab/crontab.5 View File

@@ -17,7 +17,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd January 19, 2020
.Dd March 29, 2020
.Dt CRONTAB 5
.Os
.Sh NAME
@@ -72,9 +72,6 @@ daemon.
.Ev SHELL
is set to
.Pa /bin/sh ,
.Ev PATH
is set to
.Pa /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin ,
and
.Ev LOGNAME
and
@@ -83,12 +80,22 @@ are set from the
.Pa /etc/passwd
line of the crontab's owner.
In addition, the environment variables of the
user's login class, with the exception of
.Ev PATH ,
will be set from
user's login class will be set from
.Pa /etc/login.conf.db
and
.Pa ~/.login_conf .
(A setting of
.Ev HOME
in the login class will override the value from
.Pa /etc/passwd ,
but will not change the current directory when the command is
invoked, which can only be overridden with an explicit setting of
.Ev HOME
within the crontab file itself.)
If
.Ev PATH
is not set by any other means, it is defaulted to
.Pa /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin .
.Ev HOME ,
.Ev PATH
and
@@ -109,17 +116,11 @@ On these systems,
.Ev USER
will be set also).
.Pp
In addition to
.Ev LOGNAME ,
.Ev HOME ,
.Ev PATH ,
and
.Ev SHELL ,
If
.Xr cron 8
will look at
.Ev MAILTO
if it has any reason to send mail as a result of running
commands in ``this'' crontab.
has any reason to send mail as a result of running commands in
``this'' crontab, it will respect the following settings which may be
defined in the crontab (but which are not taken from the login class).
If
.Ev MAILTO
is defined (and non-empty), mail is

+ 7
- 12
usr.sbin/cron/lib/entry.c View File

@@ -369,7 +369,8 @@ load_entry(file, error_func, pw, envp)
e->gid = pw->pw_gid;

/* copy and fix up environment. some variables are just defaults and
* others are overrides.
* others are overrides; we process only the overrides here, defaults
* are handled in do_command after login.conf is processed.
*/
e->envp = env_copy(envp);
if (e->envp == NULL) {
@@ -388,6 +389,10 @@ load_entry(file, error_func, pw, envp)
goto eof;
}
}
/* If LOGIN_CAP, this is deferred to do_command where the login class
* is processed. If !LOGIN_CAP, do it here.
*/
#ifndef LOGIN_CAP
if (!env_get("HOME", e->envp)) {
prev_env = e->envp;
sprintf(envstr, "HOME=%s", pw->pw_dir);
@@ -399,17 +404,7 @@ load_entry(file, error_func, pw, envp)
goto eof;
}
}
if (!env_get("PATH", e->envp)) {
prev_env = e->envp;
sprintf(envstr, "PATH=%s", _PATH_DEFPATH);
e->envp = env_set(e->envp, envstr);
if (e->envp == NULL) {
warn("env_set(%s)", envstr);
env_free(prev_env);
ecode = e_mem;
goto eof;
}
}
#endif
prev_env = e->envp;
sprintf(envstr, "%s=%s", "LOGNAME", pw->pw_name);
e->envp = env_set(e->envp, envstr);

Loading…
Cancel
Save