[lxc-devel] [PATCH 3/6] userns: handle delayed write errors at fclose
Stéphane Graber
stgraber at ubuntu.com
Mon Mar 4 22:01:59 UTC 2013
On 03/04/2013 03:43 PM, Serge Hallyn wrote:
> As Kees pointed out, write() errors can be delayed and returned as
> close() errors. So don't ignore error on close when writing the
> userns id mapping.
>
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
Acked-by: Stéphane Graber <stgraber at ubuntu.com>
> ---
> src/lxc/conf.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index 04ab8b8..7d70c97 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -2447,7 +2447,7 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
> int add_id_mapping(enum idtype idtype, pid_t pid, uid_t host_start, uid_t ns_start, int range)
> {
> char path[PATH_MAX];
> - int ret;
> + int ret, closeret;
> FILE *f;
>
> ret = snprintf(path, PATH_MAX, "/proc/%d/%cid_map", pid, idtype == ID_TYPE_UID ? 'u' : 'g');
> @@ -2462,9 +2462,11 @@ int add_id_mapping(enum idtype idtype, pid_t pid, uid_t host_start, uid_t ns_sta
> }
> ret = fprintf(f, "%d %d %d", ns_start, host_start, range);
> if (ret < 0)
> - perror("write");
> - fclose(f);
> - return ret < 0 ? ret : 0;
> + SYSERROR("writing id mapping");
> + closeret = fclose(f);
> + if (closeret)
> + SYSERROR("writing id mapping");
> + return ret < 0 ? ret : closeret;
> }
>
> int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
>
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130304/3131acf7/attachment.pgp>
More information about the lxc-devel
mailing list