Re: [libvirt] [PATCH][take2][1/2] add virGetUIDByUsername() and virGetGIDByGroupname()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Guido and Daniel,

On Fri, Apr 17, 2009 at 12:07 AM, Guido Günther <agx@xxxxxxxxxxx> wrote:
> Hi Ryota,
> On Thu, Apr 16, 2009 at 11:24:10PM +0900, Ryota Ozaki wrote:
>> +#ifdef HAVE_GETPWNAM_R
>> +int virGetUIDByUsername(virConnectPtr conn, char *name)
>> +{
>> +    struct passwd pwbuf;
>> +    struct passwd *pw = NULL;
>> +    char *strbuf;
>> +    size_t strbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
>
>> +
>> +    if (VIR_ALLOC_N(strbuf, strbuflen) < 0) {
>> +        virReportOOMError(conn);
>> +        return -1;
>> +    }
> We should take the same safety measures as in remoteReadConfig file
> here.
>
>> +    if (getpwnam_r(name, &pwbuf, strbuf, strbuflen, &pw) != 0 || pw == NULL) {
>> +        virReportSystemError(conn, errno,
>> +                             _("Failed to find user record for name '%s'"),
>> +                             name);
>> +        VIR_FREE(strbuf);
>> +        return -1;
>> +    }
>> +    VIR_FREE(strbuf);
>> +    return pw->pw_uid;
>> +}
>> +#endif
>> +
>> +
>> +#ifdef HAVE_GETGRNAM_R
>> +int virGetGIDByGroupname(virConnectPtr conn, char *name)
>> +{
>> +    struct group grbuf;
>> +    struct group *gr = NULL;
>> +    char *strbuf;
>> +    size_t strbuflen = sysconf(_SC_GETGR_R_SIZE_MAX);
>> +
>> +    if (VIR_ALLOC_N(strbuf, strbuflen) < 0) {
>> +        virReportOOMError(conn);
>> +        return -1;
>> +    }
> same here.
> Cheers,
>  -- Guido
>

Thanks for pointing out. I will fix them.

BTW, do you think the fix should be applied for virGetUserDirectory()
in util.c as well?

Anyway, I will resend a modified patch including Guido's fix.

Thanks!
  ozaki-r

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]