Re: [Rpm-maint] [rpm-software-management/rpm] RFC Merge RPM 4.13 OS/2 code changes (#260)

2017-10-27 Thread Gleb Fotengauer-Malinovskiy
> And we've just been considering bumping the system requirement to 
> POSIX.1-2008 (from 2001) to make certain things simpler/possible.
I think we actually already did it with aeb58f6.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/260#issuecomment-339936398___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [PATCH 5/5] Include system.h in ima and syslog plugins

2017-03-23 Thread Gleb Fotengauer-Malinovskiy
Currently, there is no harm if config.h is not included in these files
because they are not sensitive to macros defined in config.h, but any
code added later or any plugin created using these plugins as examples
might be affected by these macros and therefore has to include config.h.

An example of bug when this header is not included properly can be seen
in the previous commit.

Signed-off-by: Gleb Fotengauer-Malinovskiy <gle...@altlinux.org>
---
 plugins/ima.c| 2 ++
 plugins/syslog.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/plugins/ima.c b/plugins/ima.c
index 55a4b27..fe6d3ad 100644
--- a/plugins/ima.c
+++ b/plugins/ima.c
@@ -1,3 +1,5 @@
+#include "system.h"
+
 #include 
 #include 
 
diff --git a/plugins/syslog.c b/plugins/syslog.c
index caae016..5f22f98 100644
--- a/plugins/syslog.c
+++ b/plugins/syslog.c
@@ -1,3 +1,5 @@
+#include "system.h"
+
 #include 
 
 #include 

-- 
glebfm
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [PATCH 4/5] Fix Large File Support (LFS) in sepdebugcrcfix tool and systemd_inhibit.so plugin

2017-03-23 Thread Gleb Fotengauer-Malinovskiy
This problem was found by ALT rpm verify-elf brp script:
verify-elf: WARNING: ./usr/lib/rpm-plugins/systemd_inhibit.so: uses non-LFS 
functions: __lxstat
verify-elf: WARNING: ./usr/lib/rpm/sepdebugcrcfix: uses non-LFS functions: 
__xstat mmap open pread pwrite

Signed-off-by: Gleb Fotengauer-Malinovskiy <gle...@altlinux.org>
---
 plugins/systemd_inhibit.c | 2 ++
 tools/sepdebugcrcfix.c| 3 +++
 2 files changed, 5 insertions(+)

diff --git a/plugins/systemd_inhibit.c b/plugins/systemd_inhibit.c
index 39fbf91..29a7ae2 100644
--- a/plugins/systemd_inhibit.c
+++ b/plugins/systemd_inhibit.c
@@ -1,3 +1,5 @@
+#include "system.h"
+
 #include 
 #include 
 #include 
diff --git a/tools/sepdebugcrcfix.c b/tools/sepdebugcrcfix.c
index 1ce4f61..fab26c7 100644
--- a/tools/sepdebugcrcfix.c
+++ b/tools/sepdebugcrcfix.c
@@ -16,6 +16,9 @@
 /* Version 2013-06-24.  */
 
 #define _GNU_SOURCE
+
+#include "system.h"
+
 #include 
 #include 
 #include 

-- 
glebfm
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [PATCH 3/5] Drop local implementation of xsetprogname/xgetprogname

2017-03-23 Thread Gleb Fotengauer-Malinovskiy
It can be dropped because this code was never actually enabled.
Actually, this implementation *surely* never ever compiled.

Signed-off-by: Gleb Fotengauer-Malinovskiy <gle...@altlinux.org>
---
 misc/Makefile.am|  1 -
 misc/rpmxprogname.c | 33 -
 misc/rpmxprogname.h | 13 -
 system.h|  6 ++
 4 files changed, 2 insertions(+), 51 deletions(-)
 delete mode 100644 misc/rpmxprogname.c
 delete mode 100644 misc/rpmxprogname.h

diff --git a/misc/Makefile.am b/misc/Makefile.am
index beb9bee..bea0115 100644
--- a/misc/Makefile.am
+++ b/misc/Makefile.am
@@ -5,7 +5,6 @@ AM_CPPFLAGS += -I$(top_srcdir)/misc
 
 EXTRA_DIST = \
fnmatch.c   fnmatch.h \
-   rpmxprogname.c  rpmxprogname.h \
stpcpy.cstpncpy.c
 
 noinst_LTLIBRARIES = libmisc.la
diff --git a/misc/rpmxprogname.c b/misc/rpmxprogname.c
deleted file mode 100644
index f896006..000
--- a/misc/rpmxprogname.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Original author:  Kamil Rytarowski
-   File: rpmxprogname.c
-   Date of creation: 2013-08-10
-   License:  the same as RPM itself */
-
-#include "rpmxprogname.h"
-
-#include  /* strrchr */
-
-char *_rpmxprogname = NULL;
-
-char *_rpmxgetprogname(void)
-{
-  const char *empty = "";
-
-  if (_rpmxprognam != NULL) /* never return NULL string */
-return _rpmxprogname;
-  else
-return empty;
-}
-
-void _rpmxsetprogname(const char *pn)
-{
-  if (pn != NULL && _rpmxprogname == NULL /* set the value only once */) {
-char *p = strrchr(pn, '/'); /* locate the last occurrence of '/' */
-if (p != NULL)
-  _rpmxprogname = p + 1 /* strip beginning '/' */;
-else
-  _rpmxprogname = pn;
-  }
-}
-
-#endif /* _RPMXPROGNAME_H */
diff --git a/misc/rpmxprogname.h b/misc/rpmxprogname.h
deleted file mode 100644
index 673c84a..000
--- a/misc/rpmxprogname.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Original author:  Kamil Rytarowski
-   File: rpmxprogname.c
-   Date of creation: 2013-08-10
-   License:  the same as RPM itself */
-
-#ifndef _RPMXPROGNAME_H
-#define _RPMXPROGNAME_H
-
-char *_rpmxgetprogname(void);
-void _rpmxsetprogname(const char *pn);
-
-#endif /* _RPMXPROGNAME_H */
-
diff --git a/system.h b/system.h
index b7fafc3..6514d93 100644
--- a/system.h
+++ b/system.h
@@ -114,10 +114,8 @@ extern int fdatasync(int fildes);
 # define xsetprogname(pn) /* No need to implement it in GNU LIBC. */
   extern const char *__progname;
 # define xgetprogname(pn) __progname
-#else /* Reimplement setprogname and getprogname */
-# include "misc/rpmxprogname.h"
-# define xsetprogname(pn) _rpmxsetprogname(pn)
-# define xgetprogname() _rpmxgetprogname()
+#else
+# error "Did not find any sutable implementation of xsetprogname/xgetprogname"
 #endif
 
 /* Take care of NLS matters.  */

-- 
glebfm
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [PATCH 2/5] Only build bundled fts if system has a bad version that doesn't handle LFS

2017-03-23 Thread Gleb Fotengauer-Malinovskiy
Older versions of glibc included an fts implementation that didn't have
Large File Support on 32-bit systems.  We worked that around by bundling
fts into rpm codebase.  Thanks to Mark Wielaard, glibc >= 2.23 has LFS
support in fts.

Unfortunately, we can't drop bundled fts because we have to support
build with other libcs which do not implement fts at all or their
implementations do not provide Large File Support.

Signed-off-by: Gleb Fotengauer-Malinovskiy <gle...@altlinux.org>
---
 build/files.c| 11 ++-
 configure.ac |  3 +++
 misc/Makefile.am |  5 -
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/build/files.c b/build/files.c
index 984439d..7884768 100644
--- a/build/files.c
+++ b/build/files.c
@@ -28,7 +28,16 @@
 #include 
 
 #include "rpmio/rpmio_internal.h"  /* XXX rpmioSlurp */
-#include "misc/rpmfts.h"
+
+#ifdef HAVE_FTS_H
+# include 
+# define Fts_open fts_open
+# define Fts_read fts_read
+# define Fts_close fts_close
+#else
+# include "misc/rpmfts.h"
+#endif
+
 #include "lib/rpmfi_internal.h"/* XXX fi->apath */
 #include "lib/rpmug.h"
 #include "build/rpmbuild_internal.h"
diff --git a/configure.ac b/configure.ac
index bdcb741..687d58c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -717,6 +717,9 @@ AC_CHECK_FUNCS(
[mkstemp getcwd basename dirname realpath setenv unsetenv regcomp lchown 
utimes],
[], [AC_MSG_ERROR([function required by rpm])])
 
+AC_CHECK_HEADERS([fts.h])
+AM_CONDITIONAL([USE_BUNDLED_FTS_KLUDGE], [test "$ac_cv_header_fts_h" = no])
+
 AC_LIBOBJ(fnmatch)
 
 dnl check if python is requested
diff --git a/misc/Makefile.am b/misc/Makefile.am
index 31d264e..beb9bee 100644
--- a/misc/Makefile.am
+++ b/misc/Makefile.am
@@ -10,5 +10,8 @@ EXTRA_DIST = \
 
 noinst_LTLIBRARIES = libmisc.la
 
-libmisc_la_SOURCES = fts.c rpmfts.h
+libmisc_la_SOURCES =
+if USE_BUNDLED_FTS_KLUDGE
+libmisc_la_SOURCES += fts.c rpmfts.h
+endif
 libmisc_la_LIBADD = @LTLIBOBJS@

-- 
glebfm
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [PATCH 1/5] Rename fts.h header to rpmfts.h

2017-03-23 Thread Gleb Fotengauer-Malinovskiy
Make sure local fts.h is never included by mistake instead of system one.

Signed-off-by: Gleb Fotengauer-Malinovskiy <gle...@altlinux.org>
---
 build/files.c| 2 +-
 misc/Makefile.am | 2 +-
 misc/fts.c   | 4 ++--
 misc/{fts.h => rpmfts.h} | 0
 4 files changed, 4 insertions(+), 4 deletions(-)
 rename misc/{fts.h => rpmfts.h} (100%)

diff --git a/build/files.c b/build/files.c
index 6021643..984439d 100644
--- a/build/files.c
+++ b/build/files.c
@@ -28,7 +28,7 @@
 #include 
 
 #include "rpmio/rpmio_internal.h"  /* XXX rpmioSlurp */
-#include "misc/fts.h"
+#include "misc/rpmfts.h"
 #include "lib/rpmfi_internal.h"/* XXX fi->apath */
 #include "lib/rpmug.h"
 #include "build/rpmbuild_internal.h"
diff --git a/misc/Makefile.am b/misc/Makefile.am
index 8bf0093..31d264e 100644
--- a/misc/Makefile.am
+++ b/misc/Makefile.am
@@ -10,5 +10,5 @@ EXTRA_DIST = \
 
 noinst_LTLIBRARIES = libmisc.la
 
-libmisc_la_SOURCES = fts.c fts.h
+libmisc_la_SOURCES = fts.c rpmfts.h
 libmisc_la_LIBADD = @LTLIBOBJS@
diff --git a/misc/fts.c b/misc/fts.c
index 22509f2..5c6f53d 100644
--- a/misc/fts.c
+++ b/misc/fts.c
@@ -44,7 +44,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
 #include 
 #include 
 #include 
-#include "misc/fts.h"
+#include "misc/rpmfts.h"
 #include 
 #include 
 #include 
@@ -69,7 +69,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
 #include 
 #include 
 #include 
-#include "misc/fts.h"
+#include "misc/rpmfts.h"
 #   define __set_errno(val) (*__errno_location ()) = (val)
 #   define __open  open
 #   define __close close
diff --git a/misc/fts.h b/misc/rpmfts.h
similarity index 100%
rename from misc/fts.h
rename to misc/rpmfts.h

-- 
glebfm
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] build: error: line 73: unclosed macro or bad line continuation (broken spectool) (#175)

2017-03-13 Thread Gleb Fotengauer-Malinovskiy
Looks like `spectool` doesn't add a newline in the end of file.
Current fgetc approach expects '\n' in the end of every line.

I propose to switch to `getline(3)`.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/175#issuecomment-286158741___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [PATCH] parseSpec: use getline instead of fgetc

2017-03-13 Thread Gleb Fotengauer-Malinovskiy
Replace home-grown buggy imitation of getline(3) with use of getline(3).

Fixes: 92a8babf1b46 ("Remove hopefully the last static buffer in rpm spec 
reading")
Closes: https://github.com/rpm-software-management/rpm/issues/175
Signed-off-by: Gleb Fotengauer-Malinovskiy <gle...@altlinux.org>
---
 build/parseSpec.c | 19 ++-
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/build/parseSpec.c b/build/parseSpec.c
index 20c4555..2928e85 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -32,7 +32,7 @@ typedef struct OpenFileInfo {
 FILE *fp;
 int lineNum;
 char *readBuf;
-int readBufLen;
+size_t readBufLen;
 const char * readPtr;
 struct OpenFileInfo * next;
 } OFI_t;
@@ -323,22 +323,7 @@ retry:
 
 /* Make sure we have something in the read buffer */
 if (!(ofi->readPtr && *(ofi->readPtr))) {
-   int c;
-   int i = 0;
-
-   while ((c = fgetc(ofi->fp)) != EOF) {
-   if (i >= ofi->readBufLen - 1) {
-   ofi->readBufLen += BUFSIZ;
-   ofi->readBuf = xrealloc(ofi->readBuf, ofi->readBufLen);
-   }
-   ofi->readBuf[i++] = c;
-   if (c == '\n') {
-   ofi->readBuf[i] = '\0';
-   break;
-   }
-   }
-
-   if (!i) {
+   if (getline(>readBuf, >readBufLen, ofi->fp) <= 0) {
/* EOF, remove this file from the stack */
ofi = popOFI(spec);
 

-- 
glebfm
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint