PublicMailbox
2012-08-16 15:36:21 UTC
The patch below would permit the datacopy utility to use a dash for the password in the source or destination server parameter to mean "read from standard in". For example:
datacopy -Smyserver/myusername/-/mydatabase/mytable ...
Upon finding a dash for the password, datacopy would prompt for the password and read it in.
Using a dash for a parameter to specify "read from stdin" is a typical style for many Unix/Linux utilities.
This feature is needed to prevent the security violation of putting a password on the command line (which makes it visible to ps -f in Unix/Linux). For batch (non-interactive)
jobs in an enterprise environment, this is a mandatory requirement. Using kerberos might be better, but that's a much harder change.
Ben Slade
+++ datacopy.c 2012-08-16 11:18:55.583213000 -0400
@@ -246,6 +246,10 @@
if (!tok)
return FALSE;
pdata->spass = strdup(tok);
+ if( strcmp(pdata->spass,"-") == 0 ) {
+ printf("Enter Source Password : ");
+ pdata->spass = gets_alloc();
+ }
tok = strtok(NULL, "/");
if (!tok)
@@ -277,6 +281,10 @@
if (!tok)
return FALSE;
pdata->dpass = strdup(tok);
+ if( strcmp(pdata->dpass,"-") == 0 ) {
+ printf("Enter Destination Password : ");
+ pdata->dpass = gets_alloc();
+ }
tok = strtok(NULL, "/");
if (!tok)
datacopy -Smyserver/myusername/-/mydatabase/mytable ...
Upon finding a dash for the password, datacopy would prompt for the password and read it in.
Using a dash for a parameter to specify "read from stdin" is a typical style for many Unix/Linux utilities.
This feature is needed to prevent the security violation of putting a password on the command line (which makes it visible to ps -f in Unix/Linux). For batch (non-interactive)
jobs in an enterprise environment, this is a mandatory requirement. Using kerberos might be better, but that's a much harder change.
Ben Slade
diff -u datacopy.c.orig datacopy.c
--- datacopy.c.orig 2011-05-16 04:51:40.000000000 -0400+++ datacopy.c 2012-08-16 11:18:55.583213000 -0400
@@ -246,6 +246,10 @@
if (!tok)
return FALSE;
pdata->spass = strdup(tok);
+ if( strcmp(pdata->spass,"-") == 0 ) {
+ printf("Enter Source Password : ");
+ pdata->spass = gets_alloc();
+ }
tok = strtok(NULL, "/");
if (!tok)
@@ -277,6 +281,10 @@
if (!tok)
return FALSE;
pdata->dpass = strdup(tok);
+ if( strcmp(pdata->dpass,"-") == 0 ) {
+ printf("Enter Destination Password : ");
+ pdata->dpass = gets_alloc();
+ }
tok = strtok(NULL, "/");
if (!tok)