Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rlwrap cannot read/write its own history after sudo rlwrap in Ubuntu #39

Closed
hanslub42 opened this issue Dec 8, 2015 · 4 comments
Closed
Labels

Comments

@hanslub42
Copy link
Owner

See this question on Stack Overflow

Ubuntu's sudo preserves the value of $HOME. After a sudo rlwrap xxx xxxs history file will be owned by root, so that a subsequent invocation of rlwrap as the original user will fail with rlwrap: cannot read and write /home/user/.xxx_history: Permission denied

My first reaction would be that this is a screw-up by Ubuntu. But how do other programs avoid the problem (if at all)?

Note: the preserving of $HOME is the default under Ubuntu (they apply a special patch to sudo) but can be specified in /etc/sudoers on any system. Hence, it is not 100% fair to call this an Ubuntu problem. But I do feel that any user that messes with env_keep in /etc/sudoers can be expected to know what she is doing, while unsuspecting Ubuntu users likely will be flummoxed by this error.

In the meantime, the problem can be avoided by adding the user name to the history file name:

    rlwrap --history-filename=$HOME/.${USER}_command_history command
@hanslub42
Copy link
Owner Author

... or should rlwrap always use ~$USER instead of $HOME to construct the history filename?

@hanslub42
Copy link
Owner Author

Idea: if the history is not owned by the (real) user , treat it as read-only:

struct stat buf;

stat("bla_history", &buf);
if (buf.st_uid != getuid())
   write_histfile = FALSE;

@hanslub42
Copy link
Owner Author

hanslub42 commented Jul 24, 2016

Closed initially (incorrectly) by 4ad17ef, then by 2d7b940

@hanslub42 hanslub42 reopened this Jul 27, 2016
@hanslub42
Copy link
Owner Author

Apparenly, Ubuntu has mended its ways. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant