Re: FreeBSD and sysconf(_SC_GETPW_R_SIZE_MAX)

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

 



On Sun, May 15, 2011 at 07:22:46AM +0200, Matthias Bolte wrote:
> On FreeBSD virsh fails to enter interactive mode because
> vshReadlineInit fails, because virGetUserDirectory fails, because
> virGetUserEnt fails, because sysconf(_SC_GETPW_R_SIZE_MAX) returns -1
> and sets errno to EINVAL.
> 
> Is this something that gnulib should/could deal with, Eric?
> 
> Or should we work around it in libvrt and fallback to PATH_MAX when
> sysconf(_SC_GETPW_R_SIZE_MAX) fails?

PATH_MAX isn't expected to be available on all platforms either which
is one of the reasons for us removing its use.

getpwnam() returns ERANGE if the allocated buffer is too small. So
we should do something along the lines of

    size_t len = sysconf(_SC_GETPW_R_SIZE_MAX)
    if (len < 0)
       len = 1024;
    while (1) {
      ...
      err = getpwnam()
      if (err < 0) {
        if (errno == ERANGE) {
          len += 1024;
          continue;
        }
      }
    }


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
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]