Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151529769
D49642.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D49642.id.diff
View Options
diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc
--- a/usr.sbin/ctld/ctld.cc
+++ b/usr.sbin/ctld/ctld.cc
@@ -182,63 +182,31 @@
}
static void
-auth_check_secret_length(struct auth *auth)
+auth_check_secret_length(const struct auth_group *ag, const char *user,
+ const char *secret, const char *secret_type)
{
size_t len;
- len = strlen(auth->a_secret);
+ len = strlen(secret);
if (len > 16) {
- if (auth->a_auth_group->ag_name != NULL)
- log_warnx("secret for user \"%s\", auth-group \"%s\", "
+ if (ag->ag_name != NULL)
+ log_warnx("%s for user \"%s\", auth-group \"%s\", "
"is too long; it should be at most 16 characters "
- "long", auth->a_user, auth->a_auth_group->ag_name);
+ "long", secret_type, user, ag->ag_name);
else
- log_warnx("secret for user \"%s\", target \"%s\", "
+ log_warnx("%s for user \"%s\", target \"%s\", "
"is too long; it should be at most 16 characters "
- "long", auth->a_user,
- auth->a_auth_group->ag_target->t_name);
+ "long", secret_type, user, ag->ag_target->t_name);
}
if (len < 12) {
- if (auth->a_auth_group->ag_name != NULL)
- log_warnx("secret for user \"%s\", auth-group \"%s\", "
+ if (ag->ag_name != NULL)
+ log_warnx("%s for user \"%s\", auth-group \"%s\", "
"is too short; it should be at least 12 characters "
- "long", auth->a_user,
- auth->a_auth_group->ag_name);
+ "long", secret_type, user, ag->ag_name);
else
- log_warnx("secret for user \"%s\", target \"%s\", "
+ log_warnx("%s for user \"%s\", target \"%s\", "
"is too short; it should be at least 12 characters "
- "long", auth->a_user,
- auth->a_auth_group->ag_target->t_name);
- }
-
- if (auth->a_mutual_secret != NULL) {
- len = strlen(auth->a_mutual_secret);
- if (len > 16) {
- if (auth->a_auth_group->ag_name != NULL)
- log_warnx("mutual secret for user \"%s\", "
- "auth-group \"%s\", is too long; it should "
- "be at most 16 characters long",
- auth->a_user, auth->a_auth_group->ag_name);
- else
- log_warnx("mutual secret for user \"%s\", "
- "target \"%s\", is too long; it should "
- "be at most 16 characters long",
- auth->a_user,
- auth->a_auth_group->ag_target->t_name);
- }
- if (len < 12) {
- if (auth->a_auth_group->ag_name != NULL)
- log_warnx("mutual secret for user \"%s\", "
- "auth-group \"%s\", is too short; it "
- "should be at least 12 characters long",
- auth->a_user, auth->a_auth_group->ag_name);
- else
- log_warnx("mutual secret for user \"%s\", "
- "target \"%s\", is too short; it should be "
- "at least 12 characters long",
- auth->a_user,
- auth->a_auth_group->ag_target->t_name);
- }
+ "long", secret_type, user, ag->ag_target->t_name);
}
}
@@ -261,12 +229,12 @@
return (false);
}
+ auth_check_secret_length(ag, user, secret, "secret");
+
auth = auth_new(ag);
auth->a_user = checked_strdup(user);
auth->a_secret = checked_strdup(secret);
- auth_check_secret_length(auth);
-
return (true);
}
@@ -290,14 +258,15 @@
return (false);
}
+ auth_check_secret_length(ag, user, secret, "secret");
+ auth_check_secret_length(ag, user, secret2, "mutual secret");
+
auth = auth_new(ag);
auth->a_user = checked_strdup(user);
auth->a_secret = checked_strdup(secret);
auth->a_mutual_user = checked_strdup(user2);
auth->a_mutual_secret = checked_strdup(secret2);
- auth_check_secret_length(auth);
-
return (true);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 10, 1:14 AM (3 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31185067
Default Alt Text
D49642.id.diff (3 KB)
Attached To
Mode
D49642: ctld: Reduce code duplication in auth_check_secret_length
Attached
Detach File
Event Timeline
Log In to Comment