openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/dbus/1.12.16-r0/dbus-1.12.16/dbus/dbus-sysdeps-unix.c
dbus_bool_t _dbus_check_dir_is_private_to_user(DBusString* dir,
                                               DBusError* error)
{
    const char* directory;
    struct stat sb;

    _DBUS_ASSERT_ERROR_IS_CLEAR(error);

    directory = _dbus_string_get_const_data(dir);

    if (stat(directory, &sb) < 0)
    {
        dbus_set_error(error, _dbus_error_from_errno(errno), "%s",
                       _dbus_strerror(errno));

        return FALSE;
    }

    if (sb.st_uid != geteuid())
    {
        dbus_set_error(error, DBUS_ERROR_FAILED,
                       "%s directory is owned by user %lu, not %lu", directory,
                       (unsigned long)sb.st_uid, (unsigned long)geteuid());
        return FALSE;
    }

    if ((S_IROTH & sb.st_mode) || (S_IWOTH & sb.st_mode) ||
        (S_IRGRP & sb.st_mode) || (S_IWGRP & sb.st_mode))
    {
        dbus_set_error(error, DBUS_ERROR_FAILED,
                       "%s directory is not private to the user", directory);
        return FALSE;
    }

    return TRUE;
}
/**
 * Checks to make sure the given directory is
 * private to the user
 *
 * @param dir the name of the directory
 * @param error error return
 * @returns #FALSE on failure
 **/
Checks to make sure the given directory is
private to the user

@param dir the name of the directory
@param error error return
@returns #FALSE on failure
Checks to make sure the given directory is private to the user @param dir the name of the directory @param error error return @returns #FALSE on failure
dbus_bool_t _dbus_check_dir_is_private_to_user(DBusString* dir,
                                               DBusError* error)
{
    const char* directory;
    struct stat sb;
    _DBUS_ASSERT_ERROR_IS_CLEAR(error);
    directory = _dbus_string_get_const_data(dir);
    if (stat(directory, &sb) < 0)
    {
        dbus_set_error(error, _dbus_error_from_errno(errno), "%s",
                       _dbus_strerror(errno));
        return FALSE;
    }
    if (sb.st_uid != geteuid())
    {
        dbus_set_error(error, DBUS_ERROR_FAILED,
                       "%s directory is owned by user %lu, not %lu", directory,
                       (unsigned long)sb.st_uid, (unsigned long)geteuid());
        return FALSE;
    }
    if ((S_IROTH & sb.st_mode) || (S_IWOTH & sb.st_mode) ||
        (S_IRGRP & sb.st_mode) || (S_IWGRP & sb.st_mode))
    {
        dbus_set_error(error, DBUS_ERROR_FAILED,
                       "%s directory is not private to the user", directory);
        return FALSE;
    }
    return TRUE;
}
dbus_bool_t _dbus_check_dir_is_private_to_user ( DBusString * dir , DBusError * error ) { const char * directory ; struct stat sb ; _DBUS_ASSERT_ERROR_IS_CLEAR ( error ) ; directory = _dbus_string_get_const_data ( dir ) ; if ( stat ( directory , & sb ) < 0 ) { dbus_set_error ( error , _dbus_error_from_errno ( errno ) , " " , _dbus_strerror ( errno ) ) ; return FALSE ; } if ( sb . st_uid != geteuid ( ) ) { dbus_set_error ( error , DBUS_ERROR_FAILED , " " , directory , ( unsigned long ) sb . st_uid , ( unsigned long ) geteuid ( ) ) ; return FALSE ; } if ( ( S_IROTH & sb . st_mode ) || ( S_IWOTH & sb . st_mode ) || ( S_IRGRP & sb . st_mode ) || ( S_IWGRP & sb . st_mode ) ) { dbus_set_error ( error , DBUS_ERROR_FAILED , " " , directory ) ; return FALSE ; } return TRUE ; }
Checks to make sure the given directory is
 private to the user
Checks to make sure the given directory is private to the user