Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auth #274

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion hawk/app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def create
end
else
format.html do
flash.now[:alert] = @session.errors.first.last
if Gem.loaded_specs['rails'].version >= Gem::Version.new("6.1")
flash.now[:alert] = @session.errors.first.message
else
flash.now[:alert] = @session.errors.first.last
end
render action: 'new'
end
format.json do
Expand Down
2 changes: 1 addition & 1 deletion hawk/app/models/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Session < Tableless
end

unless $?.exitstatus == 0
record.errors[:base] << _("Invalid username or password")
record.errors.add(:base, :blank, message: "Invalid username or password")
end
end
end
Expand Down
14 changes: 11 additions & 3 deletions tools/hawk_chkpwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,18 @@ in_haclient_grp(const char *user)
return 0;
}

static int
pam_service_exists_in(const char *path, const char* name)
{
char full_path[128];
snprintf(full_path, sizeof(full_path), "%s%s", path, name);
return access(full_path, R_OK) == 0;
}

static int
sane_pam_service(const char *name)
{
const char *sp;
char path[128];

if (strlen(name) > 32)
return 0;
Expand All @@ -243,8 +250,9 @@ sane_pam_service(const char *name)
return 0;
}

snprintf(path, sizeof(path), "/etc/pam.d/%s", name);
return access(path, R_OK) == 0;
return pam_service_exists_in("/etc/pam.d/", name)
|| pam_service_exists_in("/usr/bin/", name)
|| pam_service_exists_in("/usr/sbin/", name);
}

int
Expand Down
Loading