mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-28 16:22:45 +00:00
c79d38ff0c
"semanage login -a" accepts whitespaces in user/group name (e.g. users/groups from Active Directory), which may lead to issues down the line since libsemanage doesn't expect whitespaces in /var/lib/selinux/targeted/active/seusers and other config files. Fixes: Artificial but simple reproducer # groupadd server_admins # sed -i "s/^server_admins/server admins/" /etc/group # semanage login -a -s staff_u %server\ admins # semanage login -l (or "semodule -B") libsemanage.parse_assert_ch: expected character ':', but found 'a' (/var/lib/selinux/targeted/active/seusers: 6): %server admins:staff_u:s0-s0:c0.c1023 (No such file or directory). libsemanage.seuser_parse: could not parse seuser record (No such file or directory). libsemanage.dbase_file_cache: could not cache file database (No such file or directory). libsemanage.enter_ro: could not enter read-only section (No such file or directory). FileNotFoundError: [Errno 2] No such file or directory Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
82 lines
2.7 KiB
C
82 lines
2.7 KiB
C
/* Copyright (C) 2005 Red Hat, Inc. */
|
|
|
|
#ifndef _SEMANAGE_PARSE_UTILS_INTERNAL_H_
|
|
#define _SEMANAGE_PARSE_UTILS_INTERNAL_H_
|
|
|
|
#include <stdio.h>
|
|
#include <semanage/handle.h>
|
|
|
|
typedef struct parse_info {
|
|
unsigned int lineno; /* Current line number */
|
|
char *orig_line; /* Original copy of the line being parsed */
|
|
char *working_copy; /* Working copy of the line being parsed */
|
|
char *ptr; /* Current parsing location */
|
|
|
|
const char *filename; /* Input stream file name */
|
|
FILE *file_stream; /* Input stream handle */
|
|
|
|
void *parse_arg; /* Caller supplied argument */
|
|
} parse_info_t;
|
|
|
|
/* Initialize structure */
|
|
extern int parse_init(semanage_handle_t * handle,
|
|
const char *filename,
|
|
void *parse_arg, parse_info_t ** info);
|
|
|
|
/* Release structure */
|
|
extern void parse_release(parse_info_t * info);
|
|
|
|
/* Open file */
|
|
extern int parse_open(semanage_handle_t * handle, parse_info_t * info);
|
|
|
|
/* Close file */
|
|
extern void parse_close(parse_info_t * info);
|
|
|
|
/* Release resources for current line */
|
|
extern void parse_dispose_line(parse_info_t * info);
|
|
|
|
/* Skip all whitespace and comments */
|
|
extern int parse_skip_space(semanage_handle_t * handle, parse_info_t * info);
|
|
|
|
/* Throw an error if we're at the EOF */
|
|
extern int parse_assert_noeof(semanage_handle_t * handle, parse_info_t * info);
|
|
|
|
/* Throw an error if no whitespace follows,
|
|
* otherwise eat the whitespace */
|
|
extern int parse_assert_space(semanage_handle_t * handle, parse_info_t * info);
|
|
|
|
/* Throw an error if the specified character
|
|
* does not follow, otherwise eat that character */
|
|
extern int parse_assert_ch(semanage_handle_t * handle,
|
|
parse_info_t * info, const char ch);
|
|
|
|
/* Throw an error if the specified string
|
|
* does not follow is not found, otherwise
|
|
* eat the string */
|
|
extern int parse_assert_str(semanage_handle_t * handle,
|
|
parse_info_t * info, const char *assert_str);
|
|
|
|
/* Eat the optional character, if found,
|
|
* or return STATUS_NODATA */
|
|
extern int parse_optional_ch(parse_info_t * info, const char ch);
|
|
|
|
/* Eat the optional string, if found,
|
|
* or return STATUS_NODATA */
|
|
extern int parse_optional_str(parse_info_t * info, const char *str);
|
|
|
|
/* Extract the next integer, and move
|
|
* the read pointer past it. Stop if
|
|
* the optional character delim is encountered,
|
|
* or if whitespace/eof is encountered */
|
|
int parse_fetch_int(semanage_handle_t * hgandle,
|
|
parse_info_t * info, int *num, char delim);
|
|
|
|
/* Extract the next string and move the read pointer past it.
|
|
* Stop if the optional character delim (or eof) is encountered,
|
|
* or if whitespace is encountered and allow_spaces is 0.
|
|
* Fail if the string is of length 0. */
|
|
extern int parse_fetch_string(semanage_handle_t * handle,
|
|
parse_info_t * info, char **str_ptr, char delim, int allow_spaces);
|
|
|
|
#endif
|