Reputation
Next tag badge:
99/100 score
19/20 answers
Badges
12 122 224
Newest
 Announcer
Impact
~6.6m people reached

May
11
comment Run only parts of a script as sudo, entering password only once
I think, strictly speaking, echo "$password" on the left side of a pipe is safe in a bash script. echo is a shell builtin; /bin/echo doesn't run when it's called as simply echo .... Some other shells have an echo builtin (dash, for example), but Bourne-style shells aren't required to have one. So I think echo "$password" | is acceptable in bash but may be best avoided in case someone ports the script to another shell without noticing the issue. I use a non-portable [[ instead of [ in that script to avert the same sort of problem. @KasiyA
May
11
comment How to check the password entered is a valid password for this user?
The successful authentications are logged also. sudo -l causes an entry to be written with "COMMAND=list". Btw (unrelated), while it's not objectively better to do so, using a here string in place of a here document achieves the same security goal and is more compact. Since the script already uses the bashisms read -s and &>, using if sudo -lS &>/dev/null <<<"$PASSWD"; then is no less portable. I'm not suggesting you should change what you have (it's just fine). Rather, I mention it so readers know they have this option too.
May
11
comment How to check the password entered is a valid password for this user?
This way looks excellent. Though it won't work on systems with uncommon sudo configs (as you say) and clutters /var/log/auth.log with records of each attempt, this is quick, simple, and uses an existing utility, rather than reinventing the wheel (so to speak). I suggest setting IFS= for read, to prevent false successes for whitespace-padded user input and non-padded passwords, as well as false failures for whitespace-padded user input and padded passwords. (My solution had a similar bug.) You may also want to explain how it must be run as the user whose password is being checked.
May
11
comment How can I read user input as an array in Bash?
Or simply ./array_test.sh < war_and_peace.txt.
May
11
reviewed Looks OK When Chinese ibus input is on, selecting text on Firefox textareas makes the text disappear
May
11
reviewed Looks OK Keeping old Gnome 2 while upgrading to newer versions
May
11
revised How to check the password entered is a valid password for this user?
bugfix (prevent read from stripping leading and trailing IFS whitespace)
May
11
revised For an old machine with 4 GB of RAM, is a 32-bit or 64-bit system faster?
removed notice from top (this is actually perfectly good, posted as an answer)
May
11
comment How to install a custom library written in C?
@Hunter I've expanded my answer to cover installing the CS50 fork of SPL. Hopefully this will help.
May
11
revised How to install a custom library written in C?
added instructions for installing the C-based CS50 fork (and put them at the top as they're the ones more relevant to the OP)
May
11
comment How to install a custom library written in C?
@Hunter Oh. Is the CS50 fork what you're trying to install? Or some other version?
May
11
answered How to install a custom library written in C?
May
11
comment How to install a custom library written in C?
@Hunter I'm not sure: I think I do know how, I'm working on an answer right now, and I'm testing the procedure in my answer to make sure it is really correct (or at least so it's less likely to be wrong). Of course this will only be helpful if I correctly understand what library you need to install. Btw, please note that my edit added significant information to your post, as well as attempting to make it clearer. Improving grammar was not one of my goals, though even if it had been that would have been considered appropriate.
May
11
revised How to install a custom library written in C?
reworded slightly for clarity; added link to project page for library; added tags
May
11
reviewed Reviewed How do I direct a file to be stored in a different folder?
May
11
revised How do I direct a file to be stored in a different folder?
removed unnecessary thanks; added tags
May
11
reviewed Approve MD Radeon HD 7730M (Dell Inspiron 15R Special Edition)
May
11
reviewed Edit For an old machine with 4 GB of RAM, is a 32-bit or 64-bit system faster?
May
11
revised For an old machine with 4 GB of RAM, is a 32-bit or 64-bit system faster?
I *think* this is what you meant to ask, but if not, please feel free to edit again (especially in the body where I put in what I believe is what you had intended)
May
11
reviewed Reject How can I view a progress bar when running rsync?