Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/hardened/current/master' into ha…
Browse files Browse the repository at this point in the history
…rdened/current/pie
  • Loading branch information
lattera committed Apr 11, 2016
2 parents dad709a + 2e9b0ff commit 5878050
Show file tree
Hide file tree
Showing 215 changed files with 16,476 additions and 15,369 deletions.
2 changes: 1 addition & 1 deletion bin/sh/miscbltin.c
Expand Up @@ -341,7 +341,7 @@ umaskcmd(int argc __unused, char **argv __unused)
} else {
void *set;
INTOFF;
if ((set = setmode (ap)) == 0)
if ((set = setmode (ap)) == NULL)
error("Illegal number: %s", ap);

mask = getmode (set, ~mask & 0777);
Expand Down
2 changes: 1 addition & 1 deletion bin/sh/parser.c
Expand Up @@ -628,7 +628,7 @@ simplecmd(union node **rpp, union node *redir)

/* If we don't have any redirections already, then we must reset */
/* rpp to be the address of the local redir variable. */
if (redir == 0)
if (redir == NULL)
rpp = &redir;

args = NULL;
Expand Down
8 changes: 4 additions & 4 deletions bin/sh/tests/builtins/getopts1.0
Expand Up @@ -3,7 +3,7 @@
printf -- '-1-\n'
set -- -abc
getopts "ab:" OPTION
echo ${OPTION}
printf '%s\n' "${OPTION}"

# In this case 'getopts' should realize that we have not provided the
# required argument for "-b".
Expand All @@ -14,12 +14,12 @@ echo ${OPTION}
printf -- '-2-\n'
set -- -ab
getopts "ab:" OPTION
echo ${OPTION}
printf '%s\n' "${OPTION}"
getopts "ab:" OPTION 3>&2 2>&1 >&3 3>&-
echo ${OPTION}
printf '%s\n' "${OPTION}"

# The 'shift' is aimed at causing an error.
printf -- '-3-\n'
shift 1
getopts "ab:" OPTION
echo ${OPTION}
printf '%s\n' "${OPTION}"
2 changes: 1 addition & 1 deletion bin/sh/tests/builtins/getopts2.0
Expand Up @@ -3,4 +3,4 @@ set - -ax
getopts ax option
set -C
getopts ax option
echo $option
printf '%s\n' "$option"
4 changes: 2 additions & 2 deletions bin/sh/tests/builtins/getopts9.0
Expand Up @@ -2,8 +2,8 @@

args='-ab'
getopts ab opt $args
echo $?:$opt:$OPTARG
printf '%s\n' "$?:$opt:$OPTARG"
for dummy in dummy1 dummy2; do
getopts ab opt $args
echo $?:$opt:$OPTARG
printf '%s\n' "$?:$opt:$OPTARG"
done
71 changes: 55 additions & 16 deletions cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
Expand Up @@ -50,6 +50,9 @@
#ifdef illumos
#include <libproc.h>
#endif
#ifdef __FreeBSD__
#include <spawn.h>
#endif

typedef struct dtrace_cmd {
void (*dc_func)(struct dtrace_cmd *); /* function to compile arg */
Expand Down Expand Up @@ -397,7 +400,41 @@ dof_prune(const char *fname)
free(buf);
}

#ifdef illumos
#ifdef __FreeBSD__
/*
* Use nextboot(8) to tell the loader to load DTrace kernel modules during
* the next boot of the system. The nextboot(8) configuration is removed during
* boot, so it will not persist indefinitely.
*/
static void
bootdof_add(void)
{
char * const nbargv[] = {
"nextboot", "-a",
"-e", "dtraceall_load=\"YES\"",
"-e", "dtrace_dof_load=\"YES\"",
"-e", "dtrace_dof_name=\"/boot/dtrace.dof\"",
"-e", "dtrace_dof_type=\"dtrace_dof\"",
NULL,
};
pid_t child;
int err, status;

err = posix_spawnp(&child, "nextboot", NULL, NULL, nbargv,
NULL);
if (err != 0) {
error("failed to execute nextboot: %s", strerror(err));
exit(E_ERROR);
}

if (waitpid(child, &status, 0) != child)
fatal("waiting for nextboot");
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
error("nextboot returned with status %d", status);
exit(E_ERROR);
}
}
#else
static void
etcsystem_prune(void)
{
Expand Down Expand Up @@ -508,7 +545,7 @@ etcsystem_add(void)

error("added forceload directives to %s\n", g_ofile);
}
#endif /* illumos */
#endif /* !__FreeBSD__ */

static void
print_probe_info(const dtrace_probeinfo_t *p)
Expand Down Expand Up @@ -643,24 +680,24 @@ anon_prog(const dtrace_cmd_t *dcp, dof_hdr_t *dof, int n)
p = (uchar_t *)dof;
q = p + dof->dofh_loadsz;

#ifdef illumos
oprintf("dof-data-%d=0x%x", n, *p++);

while (p < q)
oprintf(",0x%x", *p++);

oprintf(";\n");
#else
#ifdef __FreeBSD__
/*
* On FreeBSD, the DOF data is handled as a kernel environment (kenv)
* string. We use two hex characters per DOF byte.
* On FreeBSD, the DOF file is read directly during boot - just write
* two hex characters per byte.
*/
oprintf("dof-data-%d=%02x", n, *p++);
oprintf("dof-data-%d=", n);

while (p < q)
oprintf("%02x", *p++);

oprintf("\n");
#else
oprintf("dof-data-%d=0x%x", n, *p++);

while (p < q)
oprintf(",0x%x", *p++);

oprintf(";\n");
#endif

dtrace_dof_destroy(g_dtp, dof);
Expand Down Expand Up @@ -1725,8 +1762,7 @@ main(int argc, char *argv[])
#else
/*
* On FreeBSD, anonymous DOF data is written to
* the DTrace DOF file that the boot loader will
* read if booting with the DTrace option.
* the DTrace DOF file.
*/
g_ofile = "/boot/dtrace.dof";
#endif
Expand Down Expand Up @@ -1765,7 +1801,10 @@ main(int argc, char *argv[])
* that itself contains a #pragma D option quiet.
*/
error("saved anonymous enabling in %s\n", g_ofile);
#ifdef illumos

#ifdef __FreeBSD__
bootdof_add();
#else
etcsystem_add();
error("run update_drv(1M) or reboot to enable changes\n");
#endif
Expand Down
5 changes: 3 additions & 2 deletions cddl/contrib/opensolaris/cmd/zdb/zdb.c
Expand Up @@ -2156,10 +2156,11 @@ dump_label(const char *dev)
uint64_t psize, ashift;
int len = strlen(dev) + 1;

if (strncmp(dev, "/dev/dsk/", 9) == 0) {
if (strncmp(dev, ZFS_DISK_ROOTD, strlen(ZFS_DISK_ROOTD)) == 0) {
len++;
path = malloc(len);
(void) snprintf(path, len, "%s%s", "/dev/rdsk/", dev + 9);
(void) snprintf(path, len, "%s%s", ZFS_RDISK_ROOTD,
dev + strlen(ZFS_DISK_ROOTD));
} else {
path = strdup(dev);
}
Expand Down

0 comments on commit 5878050

Please sign in to comment.