/*
 * Turn NetScape's file access security off.
 * Only for NS 2.01/Solaris 2.4
 *
 * Assumes empty security manager (http://www.cs.utah.edu/~gback/netscape/empty)
 */
#define FLAG_1	(0x306400+0xB4)
#define FLAG_2	(0x306F44)

#include <assert.h>
#include <fcntl.h>

main(int ac, char *av[])
{
    char buf[20];
    int  fd, w;

    if (ac<2)
	exit(printf("Usage: %s netscape-pid\n", av[0]));

    sprintf(buf, "/proc/%05d", atoi(av[1]));

    if((fd = open(buf, O_RDWR)) == -1)
	exit(printf("couldn't access %s\n", buf));

    assert(lseek(fd, FLAG_1, 0)==FLAG_1);
    w = 0;
    assert(write(fd, &w, sizeof(int))==sizeof(int));
    assert(lseek(fd, FLAG_2, 0)==FLAG_2);
    w = 12;	/* was 4, turn bit 3 on */
    assert(write(fd, &w, sizeof(int))==sizeof(int));
    assert(close(fd)==0);
    printf("successfully enabled netscape %s\n", buf);
}
