
How to hide command line args under Solaris
I have a program that I want to hide the command line arguments on. This
piece of code worked under SunOS 4.1.x, but doesn't seem to work any
longer.
while ((ch = getopt(argc, argv, "U:P:e:a:")) != -1)
switch (ch) {
case 'U':
strcpy(user, optarg);
break;
case 'P':
strcpy(pass, optarg);
memset(optarg, ' ', strlen(optarg));
break;
case 'e':
strcpy(prog, optarg);
args[0] = calloc(strlen(optarg)+1, sizeof(char));
strcpy(args[0], optarg);
break;
case 'a':
args[ac] = calloc(strlen(optarg)+1, sizeof(char));
strcpy(args[ac++], optarg);
break;
default:
usage();
exit(-1);
break;
}
Basically, I can specify a username / password on the command line, but
I want to hide the password from a "ps -uxwwa". Under solaris, if I do
a "ps -ef", the password shows up...the memset seems ineffective.
Is there any other way to hide arguments other than prompting for them
once the program starts, which I did a little later:
if(!pass[0]) {
cp = getpass("Password: ");
if(cp) strcpy(pass, cp);
}
I believe that the isql program for sybase has the same problem running
under solaris, but we're still on 4.9.2...so perhaps they fixed it.
Thanks,
-Erik
e...@walrus.com erik.kar...@nytech.nwmarkets.com
play work