diff -urN ./plugins/check_mysql.c ../plugins/plugins/check_mysql.c --- ./plugins/check_mysql.c 2005-01-05 21:53:16.000000000 +0100 +++ ../plugins/plugins/check_mysql.c 2005-02-17 16:08:30.000000000 +0100 @@ -155,7 +155,7 @@ int process_arguments (int argc, char **argv) { - int c; + int c, i; int option = 0; static struct option longopts[] = { @@ -193,10 +193,19 @@ db = optarg; break; case 'u': /* username */ - db_user = optarg; + if((db_user = strdup(optarg))) { + for(i = 0; i < strlen(argv[optind]); i++) argv[optind][i] = 'x'; + } + else + db_user = optarg; break; case 'p': /* authentication information: password */ - db_pass = optarg; + if((db_pass = strdup(optarg))) { + /* strdup was successful, so obscure passwd from ps view */ + for(i = 0; i < strlen(argv[optind]); i++) argv[optind][i] = 'x'; + } + else /* strdup failed, so point it to password input string */ + db_pass = optarg; break; case 'P': /* critical time threshold */ db_port = atoi (optarg); @@ -219,18 +228,27 @@ while ( argc > c ) { - if (strlen(db_host) == 0) + if (db_host == NULL || strlen(db_host) == 0) { if (is_host (argv[c])) { db_host = argv[c++]; } else { usage2 (_("Invalid hostname/address"), optarg); } - else if (strlen(db_user) == 0) - db_user = argv[c++]; - else if (strlen(db_pass) == 0) - db_pass = argv[c++]; - else if (strlen(db) == 0) + } + else if (db_user == NULL || strlen(db_user) == 0) { + if((db_user = strdup(argv[c++]))) + for(i = 0; i < strlen(argv[c]); i++) argv[c][i] = 'x'; + else + db_user = argv[c]; + } + else if (db_pass == NULL || strlen(db_pass) == 0) { + if((db_pass = strdup(argv[c++]))) + for(i = 0; i < strlen(argv[c]); i++) argv[c][i] = 'x'; + else + db_pass = argv[c]; + } + else if (db == NULL || strlen(db) == 0) db = argv[c++]; else if (is_intnonneg (argv[c])) db_port = atoi (argv[c++]); @@ -246,16 +264,16 @@ validate_arguments (void) { if (db_user == NULL) - db_user = strdup(""); + db_user = ""; if (db_host == NULL) - db_host = strdup(""); + db_host = ""; if (db_pass == NULL) - db_pass == strdup(""); + db_pass == ""; if (db == NULL) - db = strdup(""); + db = ""; return OK; }