cifscreds: fix parsing of commands and parameters
Subsystems (2)
Paulo Alcantara
maintainerPATCH 1/1 cifscreds: fix parsing of commands and parameters
Fix the parsing of '--username' and '--timeout' options as both require an argument by fixing the value passed in @optstring when calling getopt_long(3).
Also fix the matching of commands by breaking the loop when an exact match is found. Otherwise cifscreds clear ... would return "Ambiguous command" due to "clearall" command.
* Before patch
$ ./cifscreds add -u testuser w22-root2.zelda.test
error: Could not resolve address for testuser
$ ./cifscreds add -u testuser -d ZELDA
Password:
$ grep 'cifs:[ad]' /proc/keys
198de7a1 I--Q--- 1 perm 0d0d0000 0 0 logon cifs:d:testuser: 13
^^ wrong desc
$ ./cifscreds clear -u testuser w22-root2.zelda.test
Ambiguous command
$ ./cifscreds clear -u testuser -d ZELDA
Ambiguous command* After patch
$ ./cifscreds add -u testuser w22-root2.zelda.test Password: $ ./cifscreds add -u testuser -d ZELDA Password: $ grep 'cifs:[ad]' /proc/keys 089183a9 I--Q--- 1 perm 0d0d0000 0 0 logon cifs:a:192.168.124.32: 17 0ca5ed80 I--Q--- 1 perm 0d0d0000 0 0 logon cifs:d:ZELDA: 17 $ ./cifscreds clear -u testuser w22-root2.zelda.test $ ./cifscreds clear -u testuser -d ZELDA
--- cifscreds.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
cifscreds.c +3 -3
@@ -71,7 +71,7 @@ static struct command commands[] = {static struct option longopts[] = { {"username" ,1 ,NULL ,'u' }, {"domain" ,0 ,NULL ,'d' }, - {"timeout" ,0 ,NULL ,'t' }, + {"timeout" ,1 ,NULL ,'t' }, {NULL ,0 ,NULL ,0 } };
@@ -477,7 +477,7 @@ int main(int argc, char **argv)if (argc ==1 )return usage (); -while ((n =getopt_long (argc, argv,"dut:" , longopts,NULL )) !=-1 ) { +while ((n =getopt_long (argc, argv,"du:t:" , longopts,NULL )) !=-1 ) {switch (n) {case 'd' : arg.keytype = (char ) n;
@@ -507,7 +507,7 @@ int main(int argc, char **argv)if (cmd->name[n] ==0 ) {/* exact match */ best = cmd; -continue ; +break ; }/* partial match */
Signature · 1 line
2.51.1
added to cifs-utils for-next
Do you know if this is a regression of cifs-utils and if so what release/when?
Quoted 78 lines · Paulo Alcantara
Fix the parsing of '--username' and '--timeout' options as both require an argument by fixing the value passed in @optstring when calling
getopt_long(3).Also fix the matching of commands by breaking the loop when an exact match is found. Otherwise
cifscreds clear ...would return "Ambiguous command" due to "clearall" command.* Before patch
$ ./cifscreds add -u testuser w22-root2.zelda.test error: Could not resolve address for testuser $ ./cifscreds add -u testuser -d ZELDA Password: $ grep 'cifs:[ad]' /proc/keys 198de7a1 I--Q--- 1 perm 0d0d0000 0 0 logon cifs:d:testuser: 13 ^^ wrong desc $ ./cifscreds clear -u testuser w22-root2.zelda.test Ambiguous command $ ./cifscreds clear -u testuser -d ZELDA Ambiguous command* After patch
$ ./cifscreds add -u testuser w22-root2.zelda.test Password: $ ./cifscreds add -u testuser -d ZELDA Password: $ grep 'cifs:[ad]' /proc/keys 089183a9 I--Q--- 1 perm 0d0d0000 0 0 logon cifs:a:192.168.124.32: 17 0ca5ed80 I--Q--- 1 perm 0d0d0000 0 0 logon cifs:d:ZELDA: 17 $ ./cifscreds clear -u testuser w22-root2.zelda.test $ ./cifscreds clear -u testuser -d ZELDAReported-by Xiaoli Feng <[email protected]>Reported-by Jay Shin <[email protected]>Signed-off-by Paulo Alcantara (Red Hat) <[email protected]>Cc Steve French <[email protected]>--- cifscreds.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)cifscreds.c +3
-4@@ -71,7 +71,7 @@ static struct command commands[] = {static struct option longopts[] = { {"username" ,1 ,NULL ,'u' }, {"domain" ,0 ,NULL ,'d' }, - {"timeout" ,0 ,NULL ,'t' }, + {"timeout" ,1 ,NULL ,'t' }, {NULL ,0 ,NULL ,0 } };@@ -477,7 +477,7 @@ int main(int argc, char **argv)if (argc ==1 )return usage (); -while ((n =getopt_long (argc, argv,"dut:" , longopts,NULL )) !=-1 ) { +while ((n =getopt_long (argc, argv,"du:t:" , longopts,NULL )) !=-1 ) {switch (n) {case 'd' : arg.keytype = (char ) n;@@ -507,7 +507,7 @@ int main(int argc, char **argv)if (cmd->name[n] ==0 ) {/* exact match */ best = cmd; -continue ; +break ; }/* partial match */ --2.51.1
Signature · 3 lines
Thanks, Steve
Paulo Alcantara
maintainerQuoted 3 lines · Steve French
added to cifs-utils for-next
Do you know if this is a regression of cifs-utils and if so what release/when?
It is regression introduced in cifs-utils-7.2.
A message that is not in the archive (sent off-list or not yet received): CAKywueTatO7NNZ=020B27vFCLvA1yb0rsWGMgnB8PKV2-Pb=oQ@mail.gmail.com
Paulo Alcantara
maintainerQuoted 1 line · Pavel Shilovsky
Is the fix urgent enough to make a release?
Yes.