Skip to content

Conversation

etbe
Copy link
Contributor

@etbe etbe commented Aug 7, 2025

No description provided.

Signed-off-by: Russell Coker <[email protected]>
@etbe
Copy link
Contributor Author

etbe commented Aug 14, 2025

@pebenito Does this need anything else?

Copy link
Member

@pebenito pebenito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @0xC0ncord for thoughts on systemd --user changes.

Comment on lines +3019 to +3071
########################################
## <summary>
## allow systemd --user to create stream sockets for a process
## </summary>
## <param name="domain">
## <summary>
## Domain to own the socket
## </summary>
## </param>
#
interface(`systemd_user_sessions_create_stream_socket',`
gen_require(`
attribute systemd_user_session_type;
')

allow systemd_user_session_type $1:unix_stream_socket { create setopt bind listen };
')

########################################
## <summary>
## allow systemd --user to create stream socket file
## </summary>
## <param name="type">
## <summary>
## type of the socket file
## </summary>
## </param>
#
interface(`systemd_user_sessions_create_sock_file',`
gen_require(`
attribute systemd_user_session_type;
')

allow systemd_user_session_type $1:sock_file { create getattr write };
')

########################################
## <summary>
## allow systemd --user to manage stream socket file
## </summary>
## <param name="type">
## <summary>
## type of the socket file
## </summary>
## </param>
#
interface(`systemd_user_sessions_manage_sock_file',`
gen_require(`
attribute systemd_user_session_type;
')

allow systemd_user_session_type $1:sock_file manage_sock_file_perms;
')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need to be changed into abstract socket and named socket activation, like is done with the pid 1 equivalents. Then the sock_file can go with the named socket activation interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this would definitely help readability of the policy too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? init_t doesn't seem to be able to do the same sorts of things.

sesearch -A -s init_t -c sock_file -p create

allow files_unconfined_type file_type:sock_file { append create execmod execute getattr ioctl link lock map mounton open quotaon read relabelfrom relabelto rename setattr unlink watch watch_mount watch_reads watch_sb watch_with_perm write };
allow filesystem_unconfined_type filesystem_type:sock_file { append create execmod execute getattr ioctl link lock map mounton open quotaon read relabelfrom relabelto rename setattr unlink watch watch_mount watch_reads watch_sb watch_with_perm write };
allow init_t init_mountpoint_type:sock_file { create open }; [ init_create_mountpoints ]:True
allow kern_unconfined unlabeled_t:sock_file { append create execmod execute getattr ioctl link lock map mounton open quotaon read relabelfrom relabelto rename setattr unlink watch watch_mount watch_reads watch_sb watch_with_perm write };

sesearch -A -s init_t -c unix_stream_socket -p create

allow unconfined_domain_type domain:unix_stream_socket { accept append bind connect connectto create getattr getopt ioctl listen lock map name_bind read recvfrom relabelfrom relabelto sendto setattr setopt shutdown write };
root@xev:/home#

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interface(`init_abstract_socket_activation',`

')

ifdef(`init_systemd',`
systemd_user_runtime_dir_unlink(ssh_agent_tmp_t, sock_file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably allow systemd --user to clean up any user temp file instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you suggest doing that? Have userdom_user_tmp_file() add an attribute to it named user_tempfile and then have an interface to allow unlinking user_tempfile attribute?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that sounds good.

Copy link
Contributor

@0xC0ncord 0xC0ncord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple comments. The rest of the systemd --user changes look good.

Comment on lines +3019 to +3071
########################################
## <summary>
## allow systemd --user to create stream sockets for a process
## </summary>
## <param name="domain">
## <summary>
## Domain to own the socket
## </summary>
## </param>
#
interface(`systemd_user_sessions_create_stream_socket',`
gen_require(`
attribute systemd_user_session_type;
')

allow systemd_user_session_type $1:unix_stream_socket { create setopt bind listen };
')

########################################
## <summary>
## allow systemd --user to create stream socket file
## </summary>
## <param name="type">
## <summary>
## type of the socket file
## </summary>
## </param>
#
interface(`systemd_user_sessions_create_sock_file',`
gen_require(`
attribute systemd_user_session_type;
')

allow systemd_user_session_type $1:sock_file { create getattr write };
')

########################################
## <summary>
## allow systemd --user to manage stream socket file
## </summary>
## <param name="type">
## <summary>
## type of the socket file
## </summary>
## </param>
#
interface(`systemd_user_sessions_manage_sock_file',`
gen_require(`
attribute systemd_user_session_type;
')

allow systemd_user_session_type $1:sock_file manage_sock_file_perms;
')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this would definitely help readability of the policy too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants