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

lib: pam_user_parser.ts add return types #21226

Merged
merged 1 commit into from
Nov 7, 2024
Merged
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
21 changes: 19 additions & 2 deletions pkg/lib/pam_user_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,24 @@
* along with Cockpit; If not, see <https://www.gnu.org/licenses/>.
*/

function parse_passwd_content(content: string) {
export interface PamCommon {
name: string,
password: string,
gid: number,
}

export interface PasswdUserInfo extends PamCommon {
uid: number,
gecos: string,
home: string,
shell: string,
}

export interface EtcGroupInfo extends PamCommon {
userlist: string[],
}

function parse_passwd_content(content: string): PasswdUserInfo[] {
if (!content) {
console.warn("Couldn't read /etc/passwd");
return [];
Expand Down Expand Up @@ -48,7 +65,7 @@ export const etc_passwd_syntax = {
parse: parse_passwd_content
};

function parse_group_content(content: string) {
function parse_group_content(content: string): EtcGroupInfo[] {
// /etc/group file is used to set only secondary groups of users. The primary group is saved in /etc/passwd-
content = (content || "").trim();
if (!content) {
Expand Down