fedelibre / LilyDev

containers and images for LilyPond contributors
9 stars 7 forks source link

Set git-bash-prompt correctly in post-install script #14

Closed michaelkaeppler closed 4 years ago

michaelkaeppler commented 4 years ago

Fixes a missing escape backslash in the heredoc string which was intended to add the output of __git_ps1 to the bash prompt.

fedelibre commented 4 years ago

@michaelkaeppler I copied it somewhere in a Fedora wiki, I think, and it worked. Are you sure it must be escaped? Isn't it to call a $declare() function? (only the last $ must be escaped to be printed in the prompt)

I'm trying to check it, but I cannot change to the dev user anymore. Do you have the same problem?

root@LilyDev:~# su dev
setgid: Operation not permitted
michaelkaeppler commented 4 years ago

Tried it with the v1 release and also with my current master. I do not have this problem switching to dev user.

Regarding to the git_ps1 thing, as I understand it: Declare is a bash builtin that is used to check if __git_ps1 is defined (thus the -F flag) If it is defined, then the output of git_ps1 is inserted into the prompt. Without escaping the $ of $(declare), the output of this function is inserted into the heredoc string at the time the postinstall script is executed. Since there is no git repo present at this point of time it simply evaluates to nothing. IMHO it should evaluate when actually forming the bash prompt, i.e. at runtime.

Does your git prompt really work with the current setup? Could you check how the corresponding line in your ~/.bashrc does look like?

Am 17.01.2020 um 14:41 schrieb Federico Bruni:

@michaelkaeppler https://github.com/michaelkaeppler I copied it somewhere in a Fedora wiki, I think, and it worked. Are you sure it must be escaped? Isn't it to call a $declare() function? (only the last $ must be escaped to be printed in the prompt)

I'm trying to check it, but I cannot change to the dev user anymore. Do you have the same problem?

|root@LilyDev:~# su dev setgid: Operation not permitted |

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fedelibre/LilyDev/pull/14?email_source=notifications&email_token=AGDYJTU5N4STGJFJCBFUCL3Q6GYRDA5CNFSM4KHEF222YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJHWXZI#issuecomment-575630309, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGDYJTWWC3Z3ZHQLWVZLAOLQ6GYRDANCNFSM4KHEF22Q.

michaelkaeppler commented 4 years ago

Maybe this issue: https://unix.stackexchange.com/questions/263634/debian-8-2-can-no-longer-su-to-root

Am 17.01.2020 um 14:41 schrieb Federico Bruni:

@michaelkaeppler https://github.com/michaelkaeppler I copied it somewhere in a Fedora wiki, I think, and it worked. Are you sure it must be escaped? Isn't it to call a $declare() function? (only the last $ must be escaped to be printed in the prompt)

I'm trying to check it, but I cannot change to the dev user anymore. Do you have the same problem?

|root@LilyDev:~# su dev setgid: Operation not permitted |

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fedelibre/LilyDev/pull/14?email_source=notifications&email_token=AGDYJTU5N4STGJFJCBFUCL3Q6GYRDA5CNFSM4KHEF222YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJHWXZI#issuecomment-575630309, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGDYJTWWC3Z3ZHQLWVZLAOLQ6GYRDANCNFSM4KHEF22Q.

fedelibre commented 4 years ago

Thanks, this helped. All the files in /usr/bin are owned by the dev user.. weird! I guess this might be a bug with the kernel or systemd version I'm running...

root@LilyDev:~# ls -l /usr/bin/su
-rwsr-xr-x. 1 dev dev 40536 May 17  2017 /usr/bin/su
root@LilyDev:~# chown root:root /usr/bin/su
root@LilyDev:~# ls -l /usr/bin/su
-rwxr-xr-x. 1 root root 40536 May 17  2017 /usr/bin/su
root@LilyDev:~# su dev
[dev@LilyDev:root]$ 

Now I can verify what you write..

fedelibre commented 4 years ago

Ah, Ok! The thing is that I make these images but I never use them :-)

[dev@LilyDev:~]$ grep 'export PS1=' .bashrc 
export PS1='[\u@\h:\W]$ '

Thanks