You are not logged in.
Pages: 1
After a recent update my at commands stopped working eg
cat ~/bin/at-test
#!/bin/sh
espeak "$(date +'%A %e of %B %Y')"
certainly works at the terminal but
echo $HOME/bin/at-test | at 22:50
seems to run, but I see a message in the journal like this
Sep 26 22:34:00 bunyip atd[11450]: pam_unix(atd:session): session opened for user robin by (uid=2)
Sep 26 22:34:00 bunyip atd[11450]: pam_unix(atd:session): session closed for user robin
Sep 26 22:34:00 bunyip atd[11450]: Exec failed for mail command: No such file or directory
so presumably I would expect a mail, but no mail arrives. Testing the mail command reveals that /usr/sbin/sendmail is missing. Do I now need to install a mail transfer agent to do simple at commands? This all worked fine until a few days ago.
Offline
What was in the update?
Offline
After a recent update
What was updated?
Testing the mail command reveals that /usr/sbin/sendmail is missing.
What package provided this file for you before?
Do I now need to install a mail transfer agent to do simple at commands?
Presumably the mail is just for STDOUT/STDERR feedback, it doesn't inhibit the job itself. If you rely on the feedback, then yes, yoeu will need something to send the mail to you. The question is -- what was doing this job for you before?
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
I think the problem relates to recent updates to bash related to the shellshock issue. After installing & configuring postfix (what a pain) for local mail I see this as the outcome of my test run
mail version v14.7.6. Type ? for help.
"/var/spool/mail/robin": 1 message 1 new
>N 1 Robin Becker Fri Sep 26 23:15 15/636 Output from your job 52
? t
[-- Message 1 -- 15 lines, 636 bytes --]:
From robin@bunyip.localdomain Fri Sep 26 23:15:00 2014
Return-Path: <robin@bunyip.localdomain>
X-Original-To: robin
Delivered-To: robin@bunyip.localdomain
Subject: Output from your job 52
To: robin@bunyip.localdomain
Date: Fri, 26 Sep 2014 23:15:00 +0100 (BST)
From: robin@bunyip.localdomain (Robin Becker)
Status: R
sh: line 31: syntax error near unexpected token `$'=\\(\\)\\ {\\ \\ history\\ \\|\\ grep\\ \\$1"\n"}''
sh: line 31: `"}; export BASH_FUNC_hsg()'
? Interrupt
?
My environment used to contain simple commands eg in my .bashrc I have
........
hsg () { history | grep $1; }
........
and at the command line the hsg command certainly shows me matching commands. However, in the new post shellshock world I'm seeing this in my environment
BASH_FUNC_hsg()=() { history | grep $1
}
so judging from my mail I'm guessing the new bash is interacting badly with the at processing.
Offline
Please use code tags when pasting to the boards https://wiki.archlinux.org/index.php/Fo … s_and_Code
at(1) is still working fine for me, with patched bash.
Offline
I did the obvious thing. After just downgrading bash with
sudo pacman -U bash-4.3.024-1-x86_64.pkg.tar.xzI find after rebooting that my at commands work again. So clearly it's the bash update to
bash-4.3.026-1-x86_64.pkg.tar.xz that causes the issue. Although probably it's something
in my .bashrc that's now become wrong. Looked more carefully at the alleged site of the
issue in my .bashrc and see I had two functions defined there
.....
psg () { ps alx -w -w -w | grep $1; }
hsg () { history | grep $1; }
export -f psg hsg
......but only the second one was mentioned in the errors.
I re-upgraded to bash-4.3.026-1-x86_64.pkg.tar.xz and then tried various experiments. I find that just removing the
export -f psg hsg from my .bashrc allows the at commands to work properly. Man bash says that export -f is OK,
but clearly for me it makes things go bad. The at errors show that it's some version of sh that's complaining, but sh==bash
so I think this is something new in bash. at(1) sin't working fine for my old environment.
Offline
Why are you exporting those functions?
at(1) runs /bin/sh but it does inherit your current environment. Exporting those functions means they are sent to the at subshell (/bin/sh) and that is choking.
Offline
When I run sh at the command line these exported functions are working fine in the shell.
robin@bunyip:~
$ sh
sh-4.3$ hsg gvim
8 gvim .bashrc
28 gvim .bashrc
51 gvim tmp/mmm
sh-4.3$ looking at the errors more closely it seems that the actual environment lines are being parsed ie the error line nos refer to the position in the output of env. The new export definition style
BASH_FUNC_hsg()=() { history | grep $1
}looks fairly complex compared to the old though so that's the problem. Perhaps it's the at command trying to parse the environment in some way.
Anyhow it shouldn't matter that my environment contains variables or functions.
This worked fine before and it's a serious regression if we're no longer allowed to export functions.
Offline
Anyhow it shouldn't matter that my environment contains variables or functions.
This worked fine before and it's a serious regression if we're no longer allowed to export functions.
For you it is a regression; everyone else currently sees it as a vulnerability. hence the patches.
Offline
I think the problem is that the bash environment is no longer parsable by bash when an exported function is present. Since even the patched bash allows functions to be exported the problem lies with bash for creating a bad environment.
robin@bunyip:~
$ export -nf psg hsg #clean out my exported functions
robin@bunyip:~
$ (env;echo echo 'hello') | bash
hello
robin@bunyip:~
$ bilbo(){
> echo 'precious'
> }
robin@bunyip:~
$ export -f bilbo
robin@bunyip:~
$ (env;echo echo 'hello') | bash
bash: line 29: syntax error near unexpected token `='
bash: line 29: `BASH_FUNC_bilbo()=() { echo 'precious''
robin@bunyip:~
$ In discussion of this vulnerability I don't see mention of forbidding exported functions.
Surely the initial problem was that trailing commands in exported function definitions would be executed.
If the intent of the 'fix' was to prevent exporting functions then that hasn't worked. Either way this is some kind of bug.
Offline
I think the problem is that the bash environment is no longer parsable by bash when an exported function is present.
Your test doesn't demonstrate anything to support your point. Only shells have limitations on what is allowed as a valid variable name, but the contents of the environment can very well contain anything -- setenv and putenv do no checking at all. Additionally, the output of "env" isn't guaranteed to be reparseable -- there's any number of things (semi-colons, whitespace, ampersands, hash) which can cause bash to fail to parse env's output correctly.
Offline
tell it to the marines and the at command; at(1) is now broken.
Offline
First, please don't be flippant. You will not find a better source of information than falconindy. Feel fortunate you attracted his attention.
Second, is this still an Archbang system? If so, you might want to take this to their forums. I cannot tell by re-reading this thread if you are seeing behavior that Jasonwryan is not, but if that is the case and you are still running Archbang, perhaps that is the issue.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
I'm not being flippant and I don't actually know who falconindy is. Anyhow appeals to authority should generally be discounted.
I think one should remember that experts got us here with both good and bad.
Elsewhere I pointed out that at(1) is in Bourne's book and is ancient in unix terms; presumably Bourne is an authority for shells, however,
he couldn't for see the existing situation where newer features have been introduced, Also the current at command is certainly not the one described in 1983.
I am not using Archbang. I use standard arch installed with the help of the code at https://github.com/helmuthdu/aui.
Looking at the source used by abs for the at command (at.c:384) I see indeed that it is writing the environment out into the file that eventually gets used to run the final command.
I suppose this should be considered a bug in at/bash since the environment when passed to sh will cause the error I see.
Perhaps there's an alternative way to pass the environment to the command or perhaps there's some alternative to at(1) that should be used.
Offline
The fact that at uses your current environment is a feature. Exporting the functions is the issue. If you insist on doing that (for no reason), then the patches just applied to bash to prevent that very behaviour will cause the issue you are seeing. How is that a problem with either at or bash?
Offline
I can in fact do without exported functions. I do claim that a change to bash has made the use
of exported functions much harder to justify. I don't see any warnings anywhere about exported
functions in the bash man pages; export -f continues to work.
The at command blindly copies the environment it's given when the at(1) command is run. Looking at the
resultant shell script the error text looks like this
BASH_FUNC_bilbo()=\(\)\ {\ \ echo\ \'precious\'"
"}; export BASH_FUNC_bilbo()the change that was made to bash to protect against injection has resulted in something that bash/sh cannot parse.
How is this not a bug? One can argue that it was never sensible for at(1) to attempt to copy the environment in this way because some environments could always be badly constructed; if that is the case then the bug is a long standing one exposed by the change in the way exported functions are stored in the environment by bash. The fact that bash can store these things that way presumably means anyone could; it's trivial to do so in eg python.
>>> os.environ['BASH_FUNC_DINGO()']="() { echo 'wow'\n}"So if the environment can contain all sorts of weirdness, is at(1) correct in blindly copying it?
Offline
So if the environment can contain all sorts of weirdness, is at(1) correct in blindly copying it?
presumably, at is supposed to execute all sorts of commands, so would it make sense for it to not?
Offline
replabrobin wrote:So if the environment can contain all sorts of weirdness, is at(1) correct in blindly copying it?
presumably, at is supposed to execute all sorts of commands, so would it make sense for it to not?
I guess the executed command needs an environment, but it could be more controlled. The difficulty in at is that it doesn't create the environment in C and then run the command with that environment; instead it tries to get sh to read the environment definitions. Very easy for the at code, but liable to breakage for bad environments or changes in sh.
The red hat guys acknowledge this issue as a bug https://bugzilla.redhat.com/show_bug.cgi?id=1147043 and have a workaround for the specific problem arising there (something called module is exported). Presumably they have reasons to use exported functions.
Offline
For what it is worth it seems the bash devs has changed the representation of exported functions in the environment and that change is in [testing] bash-4.3.027-1. If I use that versioon then it's relatively easy to make a patch to at(1) to check for the new definition and then change the way that is written to the at execution script.
If anyone were interested in that patch who would that be?
Offline
replabrobin wrote:Anyhow it shouldn't matter that my environment contains variables or functions.
This worked fine before and it's a serious regression if we're no longer allowed to export functions.For you it is a regression; everyone else currently sees it as a vulnerability. hence the patches.
I think this is incorrect; the vulnerability was that code after function definitions was immediately evaluated by bash. The (exported) functions should still work; but any code outside their definition shouldn't be executed.
For what it is worth it seems the bash devs has changed the representation of exported functions in the environment and that change is in [testing] bash-4.3.027-1. If I use that versioon then it's relatively easy to make a patch to at(1) to check for the new definition and then change the way that is written to the at execution script.
If anyone were interested in that patch who would that be?
I think you'd have to contact upstream (so either bash or at); this 'll benefit everyone and saves the arch-devs from including a custom patch in their build ![]()
Last edited by Spider.007 (2014-09-28 15:19:57)
Offline
replabrobin wrote:For what it is worth it seems the bash devs has changed the representation of exported functions in the environment and that change is in [testing] bash-4.3.027-1. If I use that versioon then it's relatively easy to make a patch to at(1) to check for the new definition and then change the way that is written to the at execution script.
If anyone were interested in that patch who would that be?
I think you'd have to contact upstream (so either bash or at); this 'll benefit everyone and saves the arch-devs from including a custom patch in their build
Looking at the gnu bash list it's not clear to me if this is to be the definitive way to define exported functions; they're talking about both prefix & suffix name changes and also a separate namespace. I'll ask there first if it's worth waiting a while.
Edit: I passed my patch up the line to a debian person.
Last edited by replabrobin (2014-09-29 16:36:27)
Offline
Pages: 1