aboutsummaryrefslogtreecommitdiff
path: root/mk/meta2deps.py
diff options
context:
space:
mode:
Diffstat (limited to 'mk/meta2deps.py')
-rwxr-xr-xmk/meta2deps.py38
1 files changed, 34 insertions, 4 deletions
diff --git a/mk/meta2deps.py b/mk/meta2deps.py
index 76ac59465b9b..bc6975182429 100755
--- a/mk/meta2deps.py
+++ b/mk/meta2deps.py
@@ -37,7 +37,7 @@ We only pay attention to a subset of the information in the
"""
RCSid:
- $Id: meta2deps.py,v 1.40 2021/12/13 19:32:46 sjg Exp $
+ $Id: meta2deps.py,v 1.44 2022/01/29 02:42:01 sjg Exp $
Copyright (c) 2011-2020, Simon J. Gerraty
Copyright (c) 2011-2017, Juniper Networks, Inc.
@@ -66,7 +66,10 @@ RCSid:
"""
-import os, re, sys
+import os
+import re
+import sys
+import stat
def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
"""
@@ -244,6 +247,7 @@ class MetaFile:
self.curdir = conf.get('CURDIR')
self.reldir = conf.get('RELDIR')
self.dpdeps = conf.get('DPDEPS')
+ self.pids = {}
self.line = 0
if not self.conf:
@@ -449,7 +453,7 @@ class MetaFile:
if self.curdir:
self.seenit(self.curdir) # we ignore this
- interesting = 'CEFLRV'
+ interesting = 'CEFLRVX'
for line in f:
self.line += 1
# ignore anything we don't care about
@@ -505,6 +509,13 @@ class MetaFile:
print("cwd=", cwd, file=self.debug_out)
continue
+ if w[0] == 'X':
+ try:
+ del self.pids[pid]
+ except KeyError:
+ pass
+ continue
+
if w[2] in self.seen:
if self.debug > 2:
print("seen:", w[2], file=self.debug_out)
@@ -518,11 +529,30 @@ class MetaFile:
continue
elif w[0] in 'ERWS':
path = w[2]
- if path == '.':
+ if w[0] == 'E':
+ self.pids[pid] = path
+ elif path == '.':
continue
self.parse_path(path, cwd, w[0], w)
assert(version > 0)
+ setid_pids = []
+ # self.pids should be empty!
+ for pid,path in self.pids.items():
+ try:
+ # no guarantee that path is still valid
+ if os.stat(path).st_mode & (stat.S_ISUID|stat.S_ISGID):
+ # we do not expect anything after Exec
+ setid_pids.append(pid)
+ continue
+ except:
+ # we do not care why the above fails,
+ # we do not want to miss the ERROR below.
+ pass
+ print("ERROR: missing eXit for {} pid {}".format(path, pid))
+ for pid in setid_pids:
+ del self.pids[pid]
+ assert(len(self.pids) == 0)
if not file:
f.close()