Plan 9 from Bell Labs’s /usr/web/sources/contrib/aganti/capDevice/src/tests/test_capuse.c

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


#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>


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

	if (argc < 2) {
		printf
		    ("usage : ./test_capuse userid1@userid2@randomstring & \n");
		exit(-1);
	}
	fd = open("/dev/capuse", O_RDWR);
	if (fd < 0)
		perror("error opening the file");

	int status;
	status = write(fd, argv[1], strlen(argv[1]));
	if (status < 0) {
		perror("error writing to the file");
		exit(-1);
	}

	printf("Capability successfully written to the /dev/capuse \n");
	printf
	    ("The user id of the process is now changed to the target user specified. Please do a 'ps -eaf | grep capuse' and verify. \n");

	while (1)
		sleep(1);

	return 0;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.