"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: struct for priv_fds
To:
gameoftrees@openbsd.org
Date:
Sun, 29 May 2022 17:35:02 +0200

Download raw body.

Thread
On Wed, May 25, 2022 at 04:44:04PM -0600, Tracey Emery wrote:
> Howdy,
> 
> I'd like to add the following to got_repository.h to prepare for adding
> multiple privileged fds to gotwebd, instead of the single one it has
> now.
> 
> ok?

Can you show how this will be used?

Each fd that is being passed around should serve a dedicated purpose.
It could be a temporary file that is used e.g. during delta application
or some other process that needs to store temporary state that may not
fit into memory. It could be a file output is written to. It could be
a file that contains input the other process will use. And so on.

With a list like this, how can we tell the purpose of each fd on the list?
Is that what the 'id' member is for?
Wouldn't it make more sense to pass required fds as function arguments?
And if multiple fds are required for a shared purpose, could we not pass
an fd array and a length instead of a list?

> diff d6a28ffe187127e3247254d7e242bb52d66eb26b /home/tracey/src/got
> blob - b6e44e8b40b8476a471c53fd10cffd4a7ff3b32d
> file + include/got_repository.h
> --- include/got_repository.h
> +++ include/got_repository.h
> @@ -177,3 +177,12 @@ const struct got_error *got_repo_get_loose_object_info
>  /* Obtain the number and size of packed objects in the repository. */
>  const struct got_error *got_repo_get_packfile_info(int *npackfiles,
>      int *nobjects, off_t *total_packsize, struct got_repository *);
> +
> +/*
> + * Container to hold a privileged fd, to be passed to non-privileged processes
> + */
> +struct got_priv_fd {
> +	TAILQ_ENTRY(got_priv_fd) entry;
> +	int			 id;
> +	int			 fd;
> +};
> 
>