Re: doas /usr/bin/vi best practice

2017-08-15 Thread Alessandro DE LAURENZIS

Hello Nam,

On Sun 13/08/2017 18:09, Nam Nguyen wrote:

If you are trying to avoid that message:

/home/just22/.exrc: not sourced: not owned by you


It could be that you are in that in your home directory and vi is trying
to read the local .exrc script on startup.

In vi(1):

exrc, ex [off]
Read the startup files in the local directory.


To turn off this feature, put "set noexrc" into your ~/.exrc



I was discussing this point privately with Martijn (in CC) and I ended 
up with exactly this conclusion.


I'm trying to sort out a bit the things and summarize what happens, in 
the hope one of the developers has the chance to have a look:


- enable the exrc option ("set exrc") in ${HOME}/.exrc
- from $HOME run: "doas vi "
- the message "/home/just22/.exrc: not sourced: not owned by you" 
 appears;
- despite the error message, the setting in $HOME/.exrc are present in 
 the vi's window, so it seems that it is sourced two times: in one case 
 all goes well, in the other there is a permission problem.


Something weird is happening, but I really don't know where...


The key is to understand what configuration files vi looks for when
starting up. This is mentioned toward the bottom of vi(1). It seems like
the precedence goes (from least to most): /etc/vi.exrc, ~/.exrc,
./.exrc.

(For clarity, I am not including ~/.nexrc and ./.nexrc.)

I used to have "set exrc" and would get the behavior you are describing,
specifically while in my home directory. Disabling that feature with
"set noexrc" removes ./.exrc from what vi scans for at startup.

This is the setup I currently have. I have /etc/vi.exrc as a system-wide
default vi configuration.

In $HOME/.exrc I have general vi macros, and in $HOME/.nexrc I have
programming language specific macros.

Normally, what I will do is update ~/.exrc if I want to add some new
features, and copy that to /etc/vi.exrc to have it available
system-wide.

Another observation I made was that because doas' default behavior is to
reset the environment except for HOME, among others, executing `doas vi`
gives me access to macros defined in both ~/.exrc ~/.nexrc even though I
am root. If I change to root with `su` and then open `vi`, I only get
access to /etc/vi.exrc and lose access to macros defined in ~/.nexrc.

I have been annoyed by this problem, too, because I had to keep pressing
enter to clear that error message, instead of the file instantaneously
opening. I could not be bothered to investigate further until you had
mentioned it.



--
Alessandro DE LAURENZIS
[mailto:jus...@atlantide.t28.net]
LinkedIn: http://it.linkedin.com/in/delaurenzis



Re: doas /usr/bin/vi best practice

2017-08-13 Thread Nam Nguyen
If you are trying to avoid that message:
> /home/just22/.exrc: not sourced: not owned by you

It could be that you are in that in your home directory and vi is trying
to read the local .exrc script on startup.

In vi(1):
> exrc, ex [off]
> Read the startup files in the local directory.

To turn off this feature, put "set noexrc" into your ~/.exrc

The key is to understand what configuration files vi looks for when
starting up. This is mentioned toward the bottom of vi(1). It seems like
the precedence goes (from least to most): /etc/vi.exrc, ~/.exrc,
./.exrc.

(For clarity, I am not including ~/.nexrc and ./.nexrc.)

I used to have "set exrc" and would get the behavior you are describing,
specifically while in my home directory. Disabling that feature with
"set noexrc" removes ./.exrc from what vi scans for at startup.

This is the setup I currently have. I have /etc/vi.exrc as a system-wide
default vi configuration.

In $HOME/.exrc I have general vi macros, and in $HOME/.nexrc I have
programming language specific macros.

Normally, what I will do is update ~/.exrc if I want to add some new
features, and copy that to /etc/vi.exrc to have it available
system-wide.

Another observation I made was that because doas' default behavior is to
reset the environment except for HOME, among others, executing `doas vi`
gives me access to macros defined in both ~/.exrc ~/.nexrc even though I
am root. If I change to root with `su` and then open `vi`, I only get
access to /etc/vi.exrc and lose access to macros defined in ~/.nexrc.

I have been annoyed by this problem, too, because I had to keep pressing
enter to clear that error message, instead of the file instantaneously
opening. I could not be bothered to investigate further until you had
mentioned it.



Re: doas /usr/bin/vi best practice

2017-08-13 Thread Raul Miller
What is the larger problem you are trying to solve?

Thanks,

-- 
Raul


On Sun, Aug 13, 2017 at 9:19 AM, Alessandro DE LAURENZIS
 wrote:
> Dear misc@ readers,
>
> I was wondering what you normally do when running vi with doas if a .exrc
> file is present in the normal user $HOME.
>
> "doas /usr/bin/vi" without any special rules will end up with:
>
> /home/just22/.exrc: not sourced: not owned by you
>
> 'cause the $HOME variable is preserved by default. The only thing that came
> to my mind was to add to doas.conf(5):
>
> permit setenv { -HOME } :wheel cmd /usr/bin/vi
>
> but I really don't know if this is the best practice.
>
> Any hints?
>
> All the best
>
> -- Alessandro DE LAURENZIS
> [mailto:jus...@atlantide.t28.net]
> LinkedIn: http://it.linkedin.com/in/delaurenzis
>



doas /usr/bin/vi best practice

2017-08-13 Thread Alessandro DE LAURENZIS

Dear misc@ readers,

I was wondering what you normally do when running vi with doas if a 
.exrc file is present in the normal user $HOME.


"doas /usr/bin/vi" without any special rules will end up with:

/home/just22/.exrc: not sourced: not owned by you

'cause the $HOME variable is preserved by default. The only thing that 
came to my mind was to add to doas.conf(5):


permit setenv { -HOME } :wheel cmd /usr/bin/vi

but I really don't know if this is the best practice.

Any hints?

All the best

-- Alessandro DE LAURENZIS
[mailto:jus...@atlantide.t28.net]
LinkedIn: http://it.linkedin.com/in/delaurenzis