X Tutup
Skip to content

Commit 16b81da

Browse files
committed
homectl: validate CIFS service name before accepting it
1 parent 68def5a commit 16b81da

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/home/homectl.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "fd-util.h"
1515
#include "fileio.h"
1616
#include "format-table.h"
17+
#include "fs-util.h"
1718
#include "glyph-util.h"
1819
#include "home-util.h"
1920
#include "homectl-fido2.h"
@@ -2446,16 +2447,14 @@ static int parse_argv(int argc, char *argv[]) {
24462447
case ARG_LOCATION:
24472448
case ARG_ICON_NAME:
24482449
case ARG_CIFS_USER_NAME:
2449-
case ARG_CIFS_DOMAIN:
2450-
case ARG_CIFS_SERVICE: {
2450+
case ARG_CIFS_DOMAIN: {
24512451

24522452
const char *field =
24532453
c == ARG_EMAIL_ADDRESS ? "emailAddress" :
24542454
c == ARG_LOCATION ? "location" :
24552455
c == ARG_ICON_NAME ? "iconName" :
24562456
c == ARG_CIFS_USER_NAME ? "cifsUserName" :
24572457
c == ARG_CIFS_DOMAIN ? "cifsDomain" :
2458-
c == ARG_CIFS_SERVICE ? "cifsService" :
24592458
NULL;
24602459

24612460
assert(field);
@@ -2475,6 +2474,25 @@ static int parse_argv(int argc, char *argv[]) {
24752474
break;
24762475
}
24772476

2477+
case ARG_CIFS_SERVICE:
2478+
if (isempty(optarg)) {
2479+
r = drop_from_identity("cifsService");
2480+
if (r < 0)
2481+
return r;
2482+
2483+
break;
2484+
}
2485+
2486+
r = parse_cifs_service(optarg, NULL, NULL, NULL);
2487+
if (r < 0)
2488+
return log_error_errno(r, "Failed to validate CIFS service name: %s", optarg);
2489+
2490+
r = json_variant_set_field_string(&arg_identity_extra, "cifsService", optarg);
2491+
if (r < 0)
2492+
return log_error_errno(r, "Failed to set cifsService field: %m");
2493+
2494+
break;
2495+
24782496
case ARG_PASSWORD_HINT:
24792497
if (isempty(optarg)) {
24802498
r = drop_from_identity("passwordHint");

0 commit comments

Comments
 (0)
X Tutup