[lxc-devel] [lxc/master] pam_cgfs: build from the same sources as liblxc

brauner on Github lxc-bot at linuxcontainers.org
Tue Aug 21 09:39:28 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180821/eb0e7e77/attachment.bin>
-------------- next part --------------
From 802d3439794a1f464198a47e72748ae2c5570c26 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 21 Aug 2018 11:35:31 +0200
Subject: [PATCH] pam_cgfs: build from the same sources as liblxc

Closes #2556.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/Makefile.am    |  15 +++++-
 src/lxc/pam/pam_cgfs.c |   1 +
 src/lxc/pam/utils.c    | 116 -----------------------------------------
 src/lxc/pam/utils.h    |  43 ---------------
 4 files changed, 15 insertions(+), 160 deletions(-)
 delete mode 100644 src/lxc/pam/utils.c
 delete mode 100644 src/lxc/pam/utils.h

diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index 75efa0a57..5f2920707 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -378,12 +378,25 @@ endif
 if ENABLE_PAM
 if HAVE_PAM
 pam_LTLIBRARIES = pam_cgfs.la
+
 pam_cgfs_la_SOURCES = pam/pam_cgfs.c \
-		      pam/utils.c pam/utils.h
+		      macro.h \
+		      utils.c utils.h
+
+if !HAVE_STRLCAT
+pam_cgfs_la_SOURCES += ../include/strlcat.c ../include/strlcat.h
+endif
+
+if !HAVE_STRLCPY
+pam_cgfs_la_SOURCES += ../include/strlcpy.c ../include/strlcpy.h
+endif
+
 pam_cgfs_la_CFLAGS = $(AM_CFLAGS)
+
 pam_cgfs_la_LIBADD = $(AM_LIBS) \
 		     $(PAM_LIBS) \
 		     -L$(top_srcdir)
+
 pam_cgfs_la_LDFLAGS = $(AM_LDFLAGS) \
 		      -avoid-version \
 		      -module \
diff --git a/src/lxc/pam/pam_cgfs.c b/src/lxc/pam/pam_cgfs.c
index 2975b6456..9a8e87760 100644
--- a/src/lxc/pam/pam_cgfs.c
+++ b/src/lxc/pam/pam_cgfs.c
@@ -57,6 +57,7 @@
 #include <security/_pam_macros.h>
 #include <security/pam_modules.h>
 
+#include "macro.h"
 #include "utils.h"
 
 #ifndef HAVE_STRLCPY
diff --git a/src/lxc/pam/utils.c b/src/lxc/pam/utils.c
deleted file mode 100644
index 5da870c58..000000000
--- a/src/lxc/pam/utils.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * lxc: linux Container library
- *
- * (C) Copyright IBM Corp. 2007, 2008
- *
- * Authors:
- * Daniel Lezcano <daniel.lezcano at free.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <sys/vfs.h>
-#include <stdarg.h>
-
-#include "utils.h"
-
-#ifndef HAVE_STRLCAT
-#include "include/strlcat.h"
-#endif
-
-bool file_exists(const char *f)
-{
-	struct stat statbuf;
-
-	return stat(f, &statbuf) == 0;
-}
-
-void *must_realloc(void *orig, size_t sz)
-{
-	void *ret;
-
-	do {
-		ret = realloc(orig, sz);
-	} while (!ret);
-
-	return ret;
-}
-
-char *must_copy_string(const char *entry)
-{
-	char *ret;
-
-	if (!entry)
-		return NULL;
-	do {
-		ret = strdup(entry);
-	} while (!ret);
-
-	return ret;
-}
-
-char *must_make_path(const char *first, ...)
-{
-	va_list args;
-	char *cur, *dest;
-	size_t full_len = strlen(first);
-	size_t buf_len;
-
-	dest = must_copy_string(first);
-
-	va_start(args, first);
-	while ((cur = va_arg(args, char *)) != NULL) {
-		full_len += strlen(cur);
-		if (cur[0] != '/')
-			full_len++;
-
-		buf_len = full_len + 1;
-		dest = must_realloc(dest, buf_len);
-
-		if (cur[0] != '/')
-			(void)strlcat(dest, "/", buf_len);
-		(void)strlcat(dest, cur, buf_len);
-	}
-	va_end(args);
-
-	return dest;
-}
-
-bool is_fs_type(const struct statfs *fs, fs_type_magic magic_val)
-{
-	return (fs->f_type == (fs_type_magic)magic_val);
-}
-
-bool has_fs_type(const char *path, fs_type_magic magic_val)
-{
-	bool has_type;
-	int ret;
-	struct statfs sb;
-
-	ret = statfs(path, &sb);
-	if (ret < 0)
-		return false;
-
-	has_type = is_fs_type(&sb, magic_val);
-
-	return has_type;
-}
diff --git a/src/lxc/pam/utils.h b/src/lxc/pam/utils.h
deleted file mode 100644
index f0a01e693..000000000
--- a/src/lxc/pam/utils.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * lxc: linux Container library
- *
- * (C) Copyright IBM Corp. 2007, 2008
- *
- * Authors:
- * Daniel Lezcano <daniel.lezcano at free.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#ifndef __PAM_UTILS_H
-#define __PAM_UTILS_H
-
-#include <sys/vfs.h>
-
-#ifndef CGROUP_SUPER_MAGIC
-#define CGROUP_SUPER_MAGIC 0x27e0eb
-#endif
-
-#ifndef CGROUP2_SUPER_MAGIC
-#define CGROUP2_SUPER_MAGIC 0x63677270
-#endif
-
-typedef __typeof__(((struct statfs *)NULL)->f_type) fs_type_magic;
-extern bool file_exists(const char *f);
-extern void *must_realloc(void *orig, size_t sz);
-extern char *must_copy_string(const char *entry);
-__attribute__((sentinel)) extern char *must_make_path(const char *first, ...);
-extern bool has_fs_type(const char *path, fs_type_magic magic_val);
-
-#endif /* __PAM_UTILS_H */


More information about the lxc-devel mailing list