Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Activity for Kamil Maciorowski‭

Type On... Excerpt Status Date
Edit Post #291290 Initial revision 7 months ago
Answer A: What are the concrete security risks of forcibly terminating a process?
> What security risks can be introduced this way, and how? Consider the following scenario: 1. A legitimate server listens on some network port. Usually¹ no other process can listen on the port. 2. The server exits. This makes the port available to other processes for listening. 3. Anothe...
(more)
7 months ago
Comment Post #290163 @#64656 "accessible in the first place?" – In Bash there is `${PIPESTATUS[@]}`, it is not affected by the `!` the answer is about. You can think of `$?` as derived from `${PIPESTATUS[@]}` according to `pipefail` (`set -o | grep pipefail`) and the presence (or not) of `!`.
(more)
7 months ago
Comment Post #291149 Why? Because `getent group` with common `nsswitch.conf` uses `/etc/group` as the database. For each user the information about the primary group is in `/etc/passwd` though, not in `/etc/group`.
(more)
7 months ago
Edit Post #289899 Post edited:
removed pointless code
about 1 year ago
Comment Post #289899 Because I forgot to remove this line. The code you see is not the first version, the answer evolved before being published. In one of my tries the script was supposed to print the content of `$lines` from within some trap. I set the variable to empty before defining this exact trap; the purpose was t...
(more)
about 1 year ago
Comment Post #289899 I wanted the script to start ignoring SIGINT as early as possible. OTOH `trap leave …` before `leave() …` would create a time window when the trap, if triggered, tries to run `leave` anyway and either fails or "succeeds" by running some other `leave`. IMO it's better here to define the trap a moment ...
(more)
about 1 year ago
Comment Post #289899 @Quasímodo The `$(…)` in your code would strip the trailing newlines I want to save. We need to append `x` *before* `$(…)` acts, only then `x` makes the trailing newline characters in fact non-trailing. Appending `x` after `$(…)` acts is too late.
(more)
about 1 year ago
Comment Post #289899 `setterm` and `tput` output escape sequences the terminal is supposed to interpret (see e.g. `tput smcup | xxd`). The sequences are garbage when not interpreted by a terminal. When not interpreted by the terminal, they cannot configure the terminal. By printing to `/dev/tty` (also from `tee`) I make ...
(more)
about 1 year ago
Comment Post #289899 `$(…)` removes *all* trailing newline characters; adding exactly one newline character when doing `printf` may or may not compensate this. By appending `x` and one newline character (this is what `echo x` does), allowing `$(…)` to remove this newline character and removing `x` "by hand" later, I capt...
(more)
about 1 year ago
Edit Post #289899 Initial revision about 1 year ago
Answer A: How to overwrite each line of STDOUT with the next one?
This other answer tries to truncate each line to make it fit the width of the terminal. It's hard to do this reliably because e.g. a tab character counts as one, but it looks like several spaces; on the other hand unprintable characters and escape sequences do not show at all. My answer is a compl...
(more)
about 1 year ago
Comment Post #289875 Another thing: each tab character in the input will count as one, but in general the terminal will move the cursor more and the truncated line will look longer than `$COLUMNS` and still wrap (see `man 1 expand`, this may help). On the other hand there may be unprintable characters that may cause the ...
(more)
about 1 year ago
Comment Post #289875 The answer does not state `$COLUMNS` is not portable. It works in "big" shells (Bash, Zsh) but `sh` is not required to support it.
(more)
about 1 year ago
Comment Post #289794 Yes, [`find-bash` is arbitrary](https://superuser.com/q/1526229/432690).
(more)
about 1 year ago
Edit Post #289794 Post edited:
about 1 year ago
Edit Post #289794 Post edited:
about 1 year ago
Edit Post #289794 Initial revision about 1 year ago
Answer A: Higher-order functions in Bash?
1. Do not embed `{}` in the shell code. If your `{}` gets expanded (by `xargs`) to `./rogue name $(reboot).txt` then `bash -c 'my-func "{}"' ` will become `bash -c 'my-func "./rogue name $(reboot).txt"' ` and `reboot` will be executed. Pathnames containing `"` will also be problematic. The right way ...
(more)
about 1 year ago
Edit Post #289608 Initial revision about 1 year ago
Answer A: Documentation for double asterisk glob expansion
While `` belongs to the POSIX standard, `` is an extension. You are right it's not in `man 7 glob`. Tools that treat `` specially (i.e. not as `` simply followed by ``) tend to agree what it means, but AFAIK it's only because there is a consensus, not because they all use some common library (like `g...
(more)
about 1 year ago
Comment Post #286257 What exactly is wrong with `dd … || the_other_method`? Does it waste time and effort because `dd` fails with I/O error not early enough? Or does `dd` return a different error after actually doing its job with a "clear data" DVD? Or what?
(more)
over 1 year ago
Comment Post #288789 I think it depends on architecture if SIGUSR1 is 10. This is one of the reasons I wrote "I won't elaborate".
(more)
over 1 year ago
Edit Post #288789 Post edited:
over 1 year ago
Edit Post #288789 Initial revision over 1 year ago
Answer A: How can I use SIGUSR1 or SIGUSR2 without risk of terminating the process?
If you are about to start the tool Start the tool from a process that already blocks or ignores SIGUSR1 and/or SIGUSR2 and let the tool inherit these settings. A blocked signal, when generated, will not be delivered to the process until the process unblocks it. An ignored signal, when delivered...
(more)
over 1 year ago
Edit Post #288788 Initial revision over 1 year ago
Question How can I use SIGUSR1 or SIGUSR2 without risk of terminating the process?
SIGUSR1 and SIGUSR2 are user-defined signals. Imagine there is a tool designed to do something useful upon receiving one or the other. The problem is the default action for these signals is `Term` (see `man 7 signal`), so it's safe to send SIGUSR1 or SIGUSR2 to the tool only after it started handl...
(more)
over 1 year ago
Edit Post #288739 Post edited:
over 1 year ago
Edit Post #288739 Post edited:
over 1 year ago
Edit Post #288739 Initial revision over 1 year ago
Answer A: Reverse shell with named pipe and netcat
I'm not sure which exact fragment, functionality or aspect is problematic to you. Here I will make points (paragraphs) about what I used to struggle to understand, or about what I suspect may be not-quite-easy to understand. Some of the below paragraphs are important for understanding later paragr...
(more)
over 1 year ago
Comment Post #288405 What tool do you use to display these names in a way that makes use of the newlines? Or how exactly do you "compare files titles"? Many modern tools sanitize such names when displaying to a human (i.e. in GUI or when printing to a terminal) and it takes some effort to make them stop. Do you use like ...
(more)
over 1 year ago
Comment Post #288401 There is this article [*Fixing Unix/Linux/POSIX Filenames: Control Characters (such as Newline), Leading Dashes, and Other Problems*](https://dwheeler.com/essays/fixing-unix-linux-filenames.html) by David A. Wheeler. Users who find the question interesting will probably find the article interesting ...
(more)
over 1 year ago
Edit Post #288384 Initial revision over 1 year ago
Answer A: When a command takes filenames as argument, how can I avoid creating temporary files?
This other answer uses process substitutions. Not every shell supports this feature. If your OS provides pathnames for file descriptors (`/dev/fd/N` or `/proc/self/fd/N`) then you can use them to achieve the desired result without process substitution and without temporary files: ls /home/alic...
(more)
over 1 year ago