Plan 9 from Bell Labs’s /usr/web/sources/patch/sorry/schtarb-plan9/none.c.orig

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include <auth.h>

void
main(int argc, char *argv[])
{
	char cmd[256];
	int fd;

	argv0 = argv[0];
	if (rfork(RFENVG|RFNAMEG) < 0)
		sysfatal("can't make new pgrp");

	fd = open("#c/user", OWRITE);
	if (fd < 0)
		sysfatal("can't open #c/user");
	if (write(fd, "none", strlen("none")) < 0)
		sysfatal("can't become none");
	close(fd);

	if (newns("none", nil) < 0)
		sysfatal("can't build namespace");

	if (argc > 1) {
		strcpy(cmd, argv[1]);
		exec(cmd, &argv[1]);
		if (strncmp(cmd, "/", 1) != 0
		&& strncmp(cmd, "./", 2) != 0
		&& strncmp(cmd, "../", 3) != 0) {
			sprint(cmd, "/bin/%s", argv[1]);
			exec(cmd, &argv[1]);
		}
	} else {
		strcpy(cmd, "/bin/rc");
		execl(cmd, cmd, nil);
	}
	sysfatal(cmd);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].