Require POSIX.1 (1990) compliance on unix

Assume unix platforms support the original POSIX.1 standard.
Specifically, assume that if G_OS_UNIX, then we have chown(),
getcwd(), getgrgid(), getpwuid(), link(), <grp.h>, <pwd.h>,
<sys/types.h>, <sys/uio.h>, <sys/wait.h>, and <unistd.h>.

Additionally, since all versions of Windows that we care about also
have <sys/types.h>, we can remove HAVE_SYS_TYPES_H checks everywhere.

Also remove one include of <sys/times.h>, and the corresponding
configure check, since the include is not currently needed (and may
always have just been a typo for <sys/time.h>).

https://bugzilla.gnome.org/show_bug.cgi?id=710519
This commit is contained in:
Dan Winship
2013-10-19 13:03:59 -04:00
parent 6e4a7fca43
commit 3981cddbf8
13 changed files with 38 additions and 99 deletions

View File

@@ -41,9 +41,6 @@
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include "gfile.h"
#include "glib/gstdio.h"

View File

@@ -143,7 +143,7 @@ g_local_file_class_init (GLocalFileClass *klass)
G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE |
G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
#ifdef HAVE_CHOWN
#ifdef G_OS_UNIX
g_file_attribute_info_list_add (list,
G_FILE_ATTRIBUTE_UNIX_UID,
G_FILE_ATTRIBUTE_TYPE_UINT32,

View File

@@ -24,6 +24,8 @@
#include "config.h"
#include <glib.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
@@ -35,10 +37,8 @@
#endif
#include <fcntl.h>
#include <errno.h>
#ifdef HAVE_GRP_H
#ifdef G_OS_UNIX
#include <grp.h>
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef HAVE_SELINUX
@@ -2158,7 +2158,7 @@ set_unix_mode (char *filename,
return TRUE;
}
#ifdef HAVE_CHOWN
#ifdef G_OS_UNIX
static gboolean
set_unix_uid_gid (char *filename,
const GFileAttributeValue *uid_value,
@@ -2442,7 +2442,7 @@ _g_local_file_info_set_attribute (char *filename,
if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) == 0)
return set_unix_mode (filename, flags, &value, error);
#ifdef HAVE_CHOWN
#ifdef G_OS_UNIX
else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_UID) == 0)
return set_unix_uid_gid (filename, &value, NULL, flags, error);
else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_GID) == 0)
@@ -2519,13 +2519,11 @@ _g_local_file_info_set_attributes (char *filename,
GError **error)
{
GFileAttributeValue *value;
#ifdef HAVE_CHOWN
#ifdef G_OS_UNIX
GFileAttributeValue *uid, *gid;
#endif
#ifdef HAVE_UTIMES
GFileAttributeValue *mtime, *mtime_usec, *atime, *atime_usec;
#endif
#if defined (HAVE_CHOWN) || defined (HAVE_UTIMES)
GFileAttributeStatus status;
#endif
gboolean res;
@@ -2555,7 +2553,7 @@ _g_local_file_info_set_attributes (char *filename,
}
#endif
#ifdef HAVE_CHOWN
#ifdef G_OS_UNIX
/* Group uid and gid setting into one call
* Change ownership before permissions, since ownership changes can
change permissions (e.g. setuid)

View File

@@ -26,9 +26,7 @@
#include <gio/gfileinfo.h>
#include <gio/gfile.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
G_BEGIN_DECLS

View File

@@ -265,7 +265,7 @@ _g_local_file_output_stream_really_close (GLocalFileOutputStream *file,
if (g_cancellable_set_error_if_cancelled (cancellable, error))
goto err_out;
#ifdef HAVE_LINK
#ifdef G_OS_UNIX
/* create original -> backup link, the original is then renamed over */
if (g_unlink (file->priv->backup_filename) != 0 &&
errno != ENOENT)

View File

@@ -28,7 +28,7 @@
#include "gvfs.h"
#include <gio/gdummyfile.h>
#include <sys/types.h>
#ifdef HAVE_PWD_H
#ifdef G_OS_UNIX
#include <pwd.h>
#endif
#include <string.h>
@@ -155,7 +155,7 @@ g_local_vfs_parse_name (GVfs *vfs,
user_prefix = g_strdup (g_get_home_dir ());
else
{
#ifdef HAVE_PWD_H
#ifdef G_OS_UNIX
struct passwd *passwd_file_entry;
char *user_name;

View File

@@ -48,7 +48,7 @@
# include <sys/filio.h>
#endif
#ifdef HAVE_SYS_UIO_H
#ifdef G_OS_UNIX
#include <sys/uio.h>
#endif