diff options
Diffstat (limited to 'web/attachments/121778-nagiosplug-cvs-check_mysql-paranoia.diff')
-rw-r--r-- | web/attachments/121778-nagiosplug-cvs-check_mysql-paranoia.diff | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/web/attachments/121778-nagiosplug-cvs-check_mysql-paranoia.diff b/web/attachments/121778-nagiosplug-cvs-check_mysql-paranoia.diff new file mode 100644 index 0000000..6639e29 --- /dev/null +++ b/web/attachments/121778-nagiosplug-cvs-check_mysql-paranoia.diff | |||
@@ -0,0 +1,89 @@ | |||
1 | diff -urN ./plugins/check_mysql.c ../plugins/plugins/check_mysql.c | ||
2 | --- ./plugins/check_mysql.c 2005-01-05 21:53:16.000000000 +0100 | ||
3 | +++ ../plugins/plugins/check_mysql.c 2005-02-17 16:08:30.000000000 +0100 | ||
4 | @@ -155,7 +155,7 @@ | ||
5 | int | ||
6 | process_arguments (int argc, char **argv) | ||
7 | { | ||
8 | - int c; | ||
9 | + int c, i; | ||
10 | |||
11 | int option = 0; | ||
12 | static struct option longopts[] = { | ||
13 | @@ -193,10 +193,19 @@ | ||
14 | db = optarg; | ||
15 | break; | ||
16 | case 'u': /* username */ | ||
17 | - db_user = optarg; | ||
18 | + if((db_user = strdup(optarg))) { | ||
19 | + for(i = 0; i < strlen(argv[optind]); i++) argv[optind][i] = 'x'; | ||
20 | + } | ||
21 | + else | ||
22 | + db_user = optarg; | ||
23 | break; | ||
24 | case 'p': /* authentication information: password */ | ||
25 | - db_pass = optarg; | ||
26 | + if((db_pass = strdup(optarg))) { | ||
27 | + /* strdup was successful, so obscure passwd from ps view */ | ||
28 | + for(i = 0; i < strlen(argv[optind]); i++) argv[optind][i] = 'x'; | ||
29 | + } | ||
30 | + else /* strdup failed, so point it to password input string */ | ||
31 | + db_pass = optarg; | ||
32 | break; | ||
33 | case 'P': /* critical time threshold */ | ||
34 | db_port = atoi (optarg); | ||
35 | @@ -219,18 +228,27 @@ | ||
36 | |||
37 | while ( argc > c ) { | ||
38 | |||
39 | - if (strlen(db_host) == 0) | ||
40 | + if (db_host == NULL || strlen(db_host) == 0) { | ||
41 | if (is_host (argv[c])) { | ||
42 | db_host = argv[c++]; | ||
43 | } | ||
44 | else { | ||
45 | usage2 (_("Invalid hostname/address"), optarg); | ||
46 | } | ||
47 | - else if (strlen(db_user) == 0) | ||
48 | - db_user = argv[c++]; | ||
49 | - else if (strlen(db_pass) == 0) | ||
50 | - db_pass = argv[c++]; | ||
51 | - else if (strlen(db) == 0) | ||
52 | + } | ||
53 | + else if (db_user == NULL || strlen(db_user) == 0) { | ||
54 | + if((db_user = strdup(argv[c++]))) | ||
55 | + for(i = 0; i < strlen(argv[c]); i++) argv[c][i] = 'x'; | ||
56 | + else | ||
57 | + db_user = argv[c]; | ||
58 | + } | ||
59 | + else if (db_pass == NULL || strlen(db_pass) == 0) { | ||
60 | + if((db_pass = strdup(argv[c++]))) | ||
61 | + for(i = 0; i < strlen(argv[c]); i++) argv[c][i] = 'x'; | ||
62 | + else | ||
63 | + db_pass = argv[c]; | ||
64 | + } | ||
65 | + else if (db == NULL || strlen(db) == 0) | ||
66 | db = argv[c++]; | ||
67 | else if (is_intnonneg (argv[c])) | ||
68 | db_port = atoi (argv[c++]); | ||
69 | @@ -246,16 +264,16 @@ | ||
70 | validate_arguments (void) | ||
71 | { | ||
72 | if (db_user == NULL) | ||
73 | - db_user = strdup(""); | ||
74 | + db_user = ""; | ||
75 | |||
76 | if (db_host == NULL) | ||
77 | - db_host = strdup(""); | ||
78 | + db_host = ""; | ||
79 | |||
80 | if (db_pass == NULL) | ||
81 | - db_pass == strdup(""); | ||
82 | + db_pass == ""; | ||
83 | |||
84 | if (db == NULL) | ||
85 | - db = strdup(""); | ||
86 | + db = ""; | ||
87 | |||
88 | return OK; | ||
89 | } | ||