#53 updatedb: can not find group `mlocate'
Opened a year ago by milahu. Modified a year ago

updatedb fails when group mlocate is missing
the output file is not written

Steps To Reproduce

Steps to reproduce the behavior:

cd $(mktemp -d)
mkdir -p a/b
touch a/b/c
# nix-shell -p mlocate # install mlocate with nix
grep mlocate /etc/group | wc -l 
# 0
updatedb --database-root ./ --output mlocate.db 
# updatedb: can not find group `mlocate'

Expected behavior

write the output file and print a warning

... or fail early when the group mlocate is missing

Workaround

updatedb --require-visibility no

Sources

https://pagure.io/mlocate/blob/master/f/src/updatedb.c

/* Set up permissions of new_db_filename.  Exit on error. */
static void
new_db_setup_permissions (void)
{
  mode_t mode;

  if (conf_check_visibility != false)
    {
      struct group *grp;

      grp = getgrnam (GROUPNAME);
      if (grp == NULL)
    error (EXIT_FAILURE, errno, _("can not find group `%s'"), GROUPNAME);
      if (chown (new_db_filename, (uid_t)-1, grp->gr_gid) != 0)
    error (EXIT_FAILURE, errno,
           _("can not change group of file `%s' to `%s'"), new_db_filename,
           GROUPNAME);
      mode = S_IRUSR | S_IWUSR | S_IRGRP;
    }
  else /* Permissions as if open (..., O_CREAT | O_WRONLY, 0666) */
    {
      mode_t mask;

      mask = umask (S_IRWXU | S_IRWXG | S_IRWXO);
      umask (mask);
      mode = ((S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
          & ~mask);
    }
  if (chmod (new_db_filename, mode) != 0)
    error (EXIT_FAILURE, errno, _("can not change permissions of file `%s'"),
       new_db_filename);
}

https://pagure.io/mlocate/blob/master/f/src/conf.h

/* true if locate(1) should check whether files are visible before reporting
   them */
extern bool conf_check_visibility;

https://pagure.io/mlocate/blob/master/f/src/conf.c

    case 'l':
      if (got_visibility != false)
        error (EXIT_FAILURE, 0, _("--%s specified twice"),
           "require-visibility");
      got_visibility = true;
      if (parse_bool (&conf_check_visibility, optarg) != 0)
        error (EXIT_FAILURE, 0, _("invalid value `%s' of --%s"), optarg,
           "require-visibility");
      break;

Login to comment on this ticket.

Metadata