summaryrefslogtreecommitdiff
path: root/setup_native/scripts/source
diff options
context:
space:
mode:
Diffstat (limited to 'setup_native/scripts/source')
-rw-r--r--setup_native/scripts/source/getuid.c135
-rw-r--r--setup_native/scripts/source/makefile.mk90
2 files changed, 225 insertions, 0 deletions
diff --git a/setup_native/scripts/source/getuid.c b/setup_native/scripts/source/getuid.c
new file mode 100644
index 000000000000..9af63f4f079d
--- /dev/null
+++ b/setup_native/scripts/source/getuid.c
@@ -0,0 +1,135 @@
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dlfcn.h>
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+#ifdef SOLARIS
+
+#include <sys/systeminfo.h>
+#include <strings.h>
+
+int chown (const char *path, uid_t owner, gid_t group) {return 0;}
+int lchown (const char *path, uid_t owner, gid_t group) {return 0;}
+int fchown (int fildes, uid_t owner, gid_t group) {return 0;}
+
+uid_t getuid (void) {return 0;}
+int stat(const char *path, struct stat *buf);
+#ifdef __notdef__
+uid_t geteuid (void) {return 0;}
+gid_t getgid (void) {return 0;}
+gid_t getegid (void) {return 0;}
+#endif
+
+int setuid (uid_t p) {return 0;}
+int setgid (gid_t p) {return 0;}
+
+/* This is to fool cpio and pkgmk */
+int fstat(int fildes, struct stat *buf)
+{
+ int ret = 0;
+ static int (*p_fstat) (int fildes, struct stat *buf) = NULL;
+ if (p_fstat == NULL)
+ p_fstat = (int (*)(int fildes, struct stat *buf))
+ dlsym (RTLD_NEXT, "fstat");
+ ret = (*p_fstat)(fildes, buf);
+ if (buf != NULL)
+ {
+ buf->st_uid = 0; /* root */
+ buf->st_gid = 2; /* bin */
+ }
+
+ return ret;
+}
+
+/* this is to fool mkdir, don't allow to remove owner execute right from directories */
+int chmod(const char *path, mode_t mode)
+{
+ int ret = 0;
+ static int (*p_chmod) (const char *path, mode_t mode) = NULL;
+ if (p_chmod == NULL)
+ p_chmod = (int (*)(const char *path, mode_t mode))
+ dlsym (RTLD_NEXT, "chmod");
+
+ if ((mode & S_IXUSR) == 0)
+ {
+ struct stat statbuf;
+ if (stat(path, &statbuf) == 0)
+ {
+ if ((statbuf.st_mode & S_IFDIR) != 0)
+ mode = (mode | S_IXUSR);
+ }
+ }
+
+ ret = (*p_chmod)(path, mode);
+ return ret;
+}
+
+
+
+/* This is to fool tar */
+int fstatat64(int fildes, const char *path, struct stat64 *buf, int flag)
+{
+ int ret = 0;
+ static int (*p_fstatat) (int fildes, const char *path, struct stat64 *buf, int flag) = NULL;
+ if (p_fstatat == NULL)
+ p_fstatat = (int (*)(int fildes, const char *path, struct stat64 *buf, int flag))
+ dlsym (RTLD_NEXT, "fstatat64");
+ ret = (*p_fstatat)(fildes, path, buf, flag);
+ if (buf != NULL)
+ {
+ buf->st_uid = 0; /* root */
+ buf->st_gid = 2; /* bin */
+ }
+
+ return ret;
+}
+#elif defined LINUX
+
+uid_t getuid (void) {return 0;}
+uid_t geteuid (void) {return 0;}
+
+/* This is to fool tar */
+#ifdef X86_64
+int __lxstat(int n, const char *path, struct stat *buf)
+{
+ int ret = 0;
+ static int (*p_lstat) (int n, const char *path, struct stat *buf) = NULL;
+ if (p_lstat == NULL)
+ p_lstat = (int (*)(int n, const char *path, struct stat *buf))
+ dlsym (RTLD_NEXT, "__lxstat");
+ ret = (*p_lstat)(n, path, buf);
+ if (buf != NULL)
+ {
+ buf->st_uid = 0; /* root */
+ buf->st_gid = 0; /* root */
+ }
+ return ret;
+}
+#else
+int __lxstat64(int n, const char *path, struct stat64 *buf)
+{
+ int ret = 0;
+ static int (*p_lstat) (int n, const char *path, struct stat64 *buf) = NULL;
+ if (p_lstat == NULL)
+ p_lstat = (int (*)(int n, const char *path, struct stat64 *buf))
+ dlsym (RTLD_NEXT, "__lxstat64");
+ ret = (*p_lstat)(n, path, buf);
+ if (buf != NULL)
+ {
+ buf->st_uid = 0;
+ buf->st_gid = 0;
+ }
+ return ret;
+}
+#endif
+#endif
+
+#ifdef _cplusplus
+}
+#endif
+
diff --git a/setup_native/scripts/source/makefile.mk b/setup_native/scripts/source/makefile.mk
new file mode 100644
index 000000000000..6933f53d6149
--- /dev/null
+++ b/setup_native/scripts/source/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=setup_native
+TARGET=getuid
+
+NO_DEFAULT_STL=TRUE
+LIBSALCPPRT=$(0)
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+# no 'lib' prefix
+DLLPRE=
+
+# no _version.o
+VERSIONOBJ=
+
+.IF "$(OS)" == "LINUX" || "$(OS)" == "SOLARIS"
+
+.IF "$(OS)" == "LINUX"
+CFLAGS+=-D_GNU_SOURCE
+.ENDIF
+
+.IF "$(OS)" == "SOLARIS"
+.IF "$(CPU)" == "I"
+.IF "$(COM)" != "GCC"
+CFLAGS+=-D_KERNEL
+.ENDIF
+.ENDIF
+.ENDIF
+
+# this object must not be a Ultra SPARC binary, this does not
+# work with /usr/bin/sort and such. Needs to be 32 bit even in
+# 64 bit builds
+.IF "$(OS)" == "SOLARIS"
+.IF "$(COM)" != "GCC"
+.IF "$(CPU)" == "S"
+ENVCFLAGS=-xarch=v8
+.ENDIF
+.IF "$(CPU)"=="U"
+CFLAGSAPPEND+=-m32
+LINKFLAGSSHL+=-m32
+.ENDIF
+.ENDIF
+.ENDIF
+
+SLOFILES = $(SLO)$/getuid.obj
+
+SHL1OBJS=$(SLOFILES)
+SHL1TARGET=$(TARGET)
+SHL1STDLIBS=-ldl
+SHL1CODETYPE=C
+
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+