diff options
| author | David M. Syzdek <david@syzdek.net> | 2020-08-13 15:41:11 -0800 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2020-08-13 15:41:11 -0800 |
| commit | fb8ac87f5fd763bbcb1dd66e263285771b816afe (patch) | |
| tree | b9f350b5e83b3bfc5f0dae334bf98899502f4c20 | |
| parent | 5ca8dad947b76673402e373988832f50207c3205 (diff) | |
| download | ldap-utils-fb8ac87f5fd763bbcb1dd66e263285771b816afe.tar.gz ldap-utils-fb8ac87f5fd763bbcb1dd66e263285771b816afe.tar.bz2 ldap-utils-fb8ac87f5fd763bbcb1dd66e263285771b816afe.tar.xz ldap-utils-fb8ac87f5fd763bbcb1dd66e263285771b816afe.zip | |
ldap2csv: adjusting CLI argument checks to require attribute if providing optional filter
| -rw-r--r-- | src/ldap2csv.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/ldap2csv.c b/src/ldap2csv.c index 1308b07..7faf38e 100644 --- a/src/ldap2csv.c +++ b/src/ldap2csv.c | |||
| @@ -311,6 +311,17 @@ int my_config(int argc, char * argv[], MyConfig ** cnfp) | |||
| 311 | 311 | ||
| 312 | cnf->prog_name = ldaputils_get_prog_name(cnf->lud); | 312 | cnf->prog_name = ldaputils_get_prog_name(cnf->lud); |
| 313 | 313 | ||
| 314 | // saves filter | ||
| 315 | if (argc > optind) | ||
| 316 | { | ||
| 317 | cnf->lud->filter = "(objectclass=*)"; | ||
| 318 | if ((index(argv[optind], '=')) != NULL) | ||
| 319 | { | ||
| 320 | cnf->lud->filter = argv[optind]; | ||
| 321 | optind++; | ||
| 322 | }; | ||
| 323 | }; | ||
| 324 | |||
| 314 | // checks for required arguments | 325 | // checks for required arguments |
| 315 | if (argc < (optind+1)) | 326 | if (argc < (optind+1)) |
| 316 | { | 327 | { |
| @@ -320,14 +331,6 @@ int my_config(int argc, char * argv[], MyConfig ** cnfp) | |||
| 320 | return(1); | 331 | return(1); |
| 321 | }; | 332 | }; |
| 322 | 333 | ||
| 323 | // saves filter | ||
| 324 | cnf->lud->filter = "(objectclass=*)"; | ||
| 325 | if ((index(argv[optind], '=')) != NULL) | ||
| 326 | { | ||
| 327 | cnf->lud->filter = argv[optind]; | ||
| 328 | optind++; | ||
| 329 | }; | ||
| 330 | |||
| 331 | // configures LDAP attributes to return in results | 334 | // configures LDAP attributes to return in results |
| 332 | len = (size_t)(argc - optind) + 1; | 335 | len = (size_t)(argc - optind) + 1; |
| 333 | size = sizeof(char *) * len; | 336 | size = sizeof(char *) * len; |
