90,103 reputation
12104220
bio website
location European Union
age
visits member for 2 years, 2 months
seen 1 hour ago

8h
comment How to log all system calls made by a process and all its descendants with auditd
@OlivierDulac, as I said, it doesn't seem you can match on pgid (or sid).
8h
comment Concatenation of two fields of two files
The join one will not work with many versions of join as join expects input lexically sorted on keys. Note that nl doesn't number every line.
8h
comment How to log all system calls made by a process and all its descendants with auditd
@OlivierDulac, marking the process in some way (that is inherited by children) is one thing I have in mind. But the list of things audit rules can match on is quite thin (not even sid, pgid...). Maybe the SELinux ones, but I don't know the first thing about SELinux. Maybe process name spaces?
8h
comment How to log all system calls made by a process and all its descendants with auditd
Thanks, but that doesn't cover "future" children, and running that in a loop frequently won't cover short-lived processes. And pid re-use would cause a problem as well.
9h
comment Count nul delimited items in file
Related: How to do head and tail on null-delimited input in bash?
1d
comment sort not working for similar entries
sort -k1,1 to sort on the first column. -b may also be needed.
1d
comment Can I use dd to quickly resilver a ZFS mirror disk?
dd would only be significantly faster if the pool was almost full as re-silvering with ZFS arrays only writes the used blocks.
1d
comment How to sort the filenames shown in grep command based on timestamp?
@Gilles, -- doesn't protect against a file called -.
2d
comment How to sort the filenames shown in grep command based on timestamp?
That runs one ls per file, so is not going to do anything wrt sorting. That also interprets the file name as shell code so is very dangerous.
2d
comment How to assign space-containing values to variables in bash using eval
Also note that the check for [:alnum:] only works in yash, ksh93 and zsh. It only works in bash in single-byte locales, and in other shells in ASCII locales, so you may want to check for ASCII alnums only.
2d
comment How to assign space-containing values to variables in bash using eval
, is just the , operator. +, -.... would work as well.
2d
comment How to assign space-containing values to variables in bash using eval
Now, with the latest edit, you might as well do a case $varname in ("" | *[!_[:alnum:]]* | [[:digit:]]*) invalid; esac Or even ("" | [!_[:alnum:]]) since you're adding a _ prefix anyway.
2d
comment How to assign space-containing values to variables in bash using eval
Sorry, (rm -rf / 1)+a is wrong since you strip the )+a. In the case of a='b[$(id >&2)]' varname='a,b' bash -c ': "$((${varname%%*[`\)]*}$$=0))"', you're evaluating a,b1234=0 as an arithmetic expression and that a is recursively evaluated which is where you've got the code injection (that is why it's known (not as widely as one would like) that you mustn't use external data in arithmetic evaluations).
2d
comment How to assign space-containing values to variables in bash using eval
Still doesn't exclude invalid variables like (rm -rf / 1)+a or a,b, and can have nasty side effects like with PATH=42,a or execute arbitrary code like with a='a[$(id >&2)]' varname='a,b'
2d
comment How to assign space-containing values to variables in bash using eval
Try with varname='a[`echo rm -rf / >&2`],a' with bash for instance.
2d
comment How to assign space-containing values to variables in bash using eval
You'll want unset -v -- ... as well.
2d
comment How to assign space-containing values to variables in bash using eval
In practice, zsh, pdksh, mksh, yash don't complain on unset 'a;b'.
Oct
27
comment How does `cat <> file` work?
<> is also useful on some systems (like Linux) to open named pipes without blocking until another process opens it for writing.
Oct
27
comment How can I remove lines matching foo but not matching bar?
@Anthon, the requirement is in the question's subject. How can I remove lines matching foo but not matching bar?. And this answer addresses it.
Oct
27
comment How does `cat <> file` work?
While reading from stdout is generally not useful, 1<> the-file often is as it also does not truncate the-file. <> was introduced by the Bourne shell, so would work in any Bourne-like shell.