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

How to set the label to some files or directories when system boot up #134

Open
xdsb opened this issue Dec 5, 2022 · 9 comments
Open

How to set the label to some files or directories when system boot up #134

xdsb opened this issue Dec 5, 2022 · 9 comments

Comments

@xdsb
Copy link

xdsb commented Dec 5, 2022

How to set the label to some files or directories automatically when system boot up ? not like using the smack-util tool chsmack "chsmack -a 'attr' file" in terminal after linux system boot up. Just like setting file_contexts in SELINUX
Thank you.

@cschaufler
Copy link
Contributor

cschaufler commented Dec 5, 2022 via email

@xdsb
Copy link
Author

xdsb commented Dec 6, 2022

smack with systemd, and I want to set smack labels for some files and directories in the rootfs so that the labels would be set at a system boot automatically, just likeing using make_ext4fs with option -S file_contexts to set labels in SElinux when making rootfs img,
could I also set smack labels by this way?

@cschaufler
Copy link
Contributor

cschaufler commented Dec 6, 2022 via email

@xdsb
Copy link
Author

xdsb commented Dec 6, 2022

OKay,,thank you for your reply.
So,how to set smack labels to files or directories at system boot up? Is there any solution?

@cschaufler
Copy link
Contributor

cschaufler commented Dec 6, 2022 via email

@xdsb
Copy link
Author

xdsb commented Dec 6, 2022

Yeah,we use systemd as system management.

@cschaufler
Copy link
Contributor

cschaufler commented Dec 6, 2022 via email

@jobol
Copy link
Member

jobol commented Dec 6, 2022

When using yocto, some of the labelling made in post install of packets are managed using pseudo. It emulates system calls and takes care of security attributes. There is some magic to then apply it in the image either directly or at first boot. But it does not solves transmutations issues because it does neither know nor emulate the process labels.

In my opinion, you are looking for a tool that based on some predefined rules enforce smack labels on files. A such official Smack's tool doesn't exist, AFAIK.

@xdsb
Copy link
Author

xdsb commented Dec 7, 2022

yeah,@jobol, we just want to set labels to files or directories in the rootfs at system boot or set labels at making rootfs image just like "make_ext4fs -S file_context" in Selinux,
file_contexts:
###########################################
# Root
/ u:object_r:rootfs:s0
# Data files
/adb_keys u:object_r:adb_keys_file:s0
/build.prop u:object_r:rootfs:s0
/default.prop u:object_r:rootfs:s0
# Executables
/init u:object_r:init_exec:s0
......
###########################################
and then system load predefined rules files that are installed into /etc/smack/accesses.d(such as default-access-domains,...)

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

No branches or pull requests

3 participants