linux-surface / iptsd

Userspace daemon for Intel Precise Touch & Stylus
GNU General Public License v2.0
86 stars 39 forks source link

Improve scripts and fix error #104

Closed m1nicrusher closed 1 year ago

m1nicrusher commented 1 year ago

Remove $ sign to allow copy & paste & run. Expanded semanage codes since * won't work.

StollD commented 1 year ago

I kinda like having the dollar sign, because it means that you have to somewhat think about what you are doing. You cant just do Ctrl-A and Ctrl-C.

And why are the wildcards not working? Does semanage not support multiple paths? I vaguely remember that semanage also supports wildcards by itself, does it work if the path is wrapped with ''?

NP-chaonay commented 1 year ago

IMHO

Remove $ sign to allow copy & paste & run.

if that code is not designed to be copy&paste directly, then this may not required, the $ and # is indicate that if that command required root or not

Expanded semanage codes since * won't work.

it also depend on shell that using, so maybe we may set the defination if the given command line required some specific shell (bash/sh?) or not.

BTW I'm neutral on this because not know much context

m1nicrusher commented 1 year ago

I kinda like having the dollar sign, because it means that you have to somewhat think about what you are doing. You cant just do Ctrl-A and Ctrl-C.

OK then, a valid point.

And why are the wildcards not working? Does semanage not support multiple paths? I vaguely remember that semanage also supports wildcards by itself, does it work if the path is wrapped with ''?

I'm using zsh and wildcards expanded the multiple paths into multiple arguments, which semanage then posted an error about too many arguments.

For example if we have /etc/a and /etc/b, doing semanage --flags /etc/* will convert it into semanage --flags /etc/a /etc/b and it will complain about "/etc/b" as an excess argument that is hence not recognised.

(I don't quite remember the detailed error message but it was not until I manually expanded the paths into separate commands that it started to work.)

I'm currently travelling with a SP8 with only Windows on it, if someone want to verify that?

m1nicrusher commented 1 year ago

I have re-added the $ sign at each line of code if that's preferred. I've tested the wildcard to a brand new install of Fedora with zsh as shell.

This is what I get:

$ sudo semanage fcontext -a -t usr_t -s system_u /usr/local/bin/ipts*
usage: semanage [-h]
                {import,export,login,user,port,ibpkey,ibendport,interface,module,node,fcontext,boolean,permissive,dontaudit}
                ...
semanage: error: unrecognized arguments: /usr/local/bin/iptsd-calibrate /usr/local/bin/iptsd-dump /usr/local/bin/iptsd-find-hidraw /usr/local/bin/iptsd-perf /usr/local/bin/iptsd-plot /usr/local/bin/iptsd-show

In this case, it does not allow multiple target arguments in single execute.

StollD commented 1 year ago

So, I was fairly sure that semanage supported wildcards (passed in single quotes so they are not evaluated by the shell), but after looking it up it seems that it actually supports regular expressions.

So, what about something like this? sudo semanage fcontext -a -t usr_t -s system_u '/usr/local/bin/ipts.*'

m1nicrusher commented 1 year ago

sudo semanage fcontext -a -t usr_t -s system_u '/usr/local/bin/ipts.*'

Looks like it works fine on my machine. This is indeed much neater.

It seems like semanage supports regex but not restorecon. restorecon supports wildcard however, so I'll keep the wildcard usage in that one. (Very weird design, probably by different bunch of people)

sudo restorecon -vF '/usr/local/bin/ipts.*'
restorecon: lstat(/usr/local/bin/ipts.*) failed: No such file or directory

sudo restorecon -vF /usr/local/bin/ipts*  
Relabeled /usr/local/bin/iptsd-plot from system_u:object_r:bin_t:s0 to system_u:object_r:usr_t:s0
Relabeled /usr/local/bin/iptsd-show from system_u:object_r:bin_t:s0 to system_u:object_r:usr_t:s0
StollD commented 1 year ago

Thank you!