vere icon indicating copy to clipboard operation
vere copied to clipboard

conn: do not chdir for conn.sock

Open mrdomino opened this issue 1 year ago • 8 comments

Instead, we create the socket in a temporary directory - TMPDIR if it is not too long, or else /tmp. The directory is made via mkdtemp with the template urbit-XXXXXX. The socket is located there (getting around the length limit) and $pier/.urb/conn.sock is symlinked to it.

This fixes an issue where if urbit is started with sudo -u pieruser from a directory that the pier user doesn't have access to (e.g. a different user's home directory that is chmod 0750), the process would die trying to chdir back to the old directory.

It also gives clients more flexibility; previously, they would have had to chdir to the pier directory to connect to the socket without risking overrunning the length limit. They can still do that (and use ".urb/conn.sock" as their sun_path), but they now also have the option of using readlink and connecting to the full absolute path of the socket without changing directories.

Replaces calls to uv_strerror with strerror for system calls; the former does not print system call errors properly.

Supersedes #580.

mrdomino avatar Jan 05 '24 02:01 mrdomino

I'm actually indifferent as to whether this or #580 is taken. I think this is a slightly better solution, since it allows clients to always be able to specify the full absolute path to the socket when connecting to it. But either way is fine.

mrdomino avatar Jan 05 '24 02:01 mrdomino

@pkova Are you the right person to review this?

mrdomino avatar Jan 08 '24 18:01 mrdomino

Oh, I guess now there's also lick.c.

In that case the temporary directory should probably be stored on u3_Host or u3C or something and created in main.c. Right?

mrdomino avatar Jan 08 '24 20:01 mrdomino

@mopfel-winrux how do you want to handle %lick? I don't have much insight yet into what it's doing. Would it make sense for it to follow suit with this change and use a tmp directory for its sockets?

If not, then the next best thing is probably to reopen #580 and also apply that to lick.c.

mrdomino avatar Jan 11 '24 00:01 mrdomino

@mrdomino I'm sorry I completely missed this. We should also do this for lick.c

mopfel-winrux avatar Mar 03 '24 01:03 mopfel-winrux

Yeah. How does lick work? Does it make one socket or many?

I guess it's going to be necessary to track and manage the temp dir from some location that is neither conn.c nor lick.c if we go this route.

I also gave a little thought to putting the socket directory under /run/urbit/sampel-palnet rather than /tmp/urbit-XXXXXX. I'm leaning towards /tmp at the moment, but could be persuaded either way. On Saturday, March 2nd, 2024 at 17:56, mopfel-winrux @.***> wrote:

@.***(https://github.com/mrdomino) I'm sorry I completely missed this. We should also do this for lick.c

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

mrdomino avatar Mar 11 '24 02:03 mrdomino

It makes multiple sockets. One per [%spin name=path] card it is given. It puts them in `.urb/dev/ folder under the name path. we could use that directory

mopfel-winrux avatar Mar 11 '24 13:03 mopfel-winrux

Ok, so supposing we want to keep sockets symlinked in the pier directory, maybe we can just do a symlink from dev​ under the temp directory to dev​ under the pier directory?

On Monday, March 11th, 2024 at 06:32, mopfel-winrux @.***> wrote:

It makes multiple sockets. One per [%spin name=path] card it is given. It puts them in `.urb/dev/ folder under the name path. we could use that directory

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

mrdomino avatar Mar 11 '24 16:03 mrdomino