#
from __future__ import print_function
-import os, pwd, sys, ConfigParser, getopt, tempfile, shutil, datetime, commands
+import os, pwd, sys, stat
+import ConfigParser, getopt, tempfile, shutil, datetime, commands
version = "1.12"
if __name__ == '__main__':
name = email = project = token = url = None
- config = ConfigParser.RawConfigParser()
- if os.path.exists(os.path.expanduser("~/.config/coverity-submit")):
- config.read(os.path.expanduser("~/.config/coverity-submit"))
- else:
- config.read(os.path.expanduser("~/.coverity-submit"))
+ cfgpaths = [os.path.expanduser(x)
+ for x in ("~/.config/coverity-submit", "~/.coverity-submit")
+ if os.path.exists(os.path.expanduser(x))]
+
+ # Security fix
+ for path in cfgpaths:
+ if stat.S_IMODE(os.stat(path).st_mode) != (stat.S_IRUSR | stat.S_IWUSR):
+ sys.stderr.write("coverity-submit: fixing insecure permissions.\n")
+ os.chmod(path, stat.S_IRUSR | stat.S_IWUSR)
def die(complaint):
- sys.stderr.write(complaint + "\n")
+ sys.stderr.write("coverity-submit: " + complaint + "\n")
sys.exit(1)
- # Gather information that is not project-specific
+ if len(cfgpaths) == 2:
+ die("Multiple configuration files.")
+ config = ConfigParser.RawConfigParser()
+ if len(cfgpaths) == 1:
+ config.read(cfgpaths[0])
+
+ # Gather information that is not project-specific
if not "ALL" in config.sections():
config.add_section("ALL")
if not config.has_option("ALL", "name"):
can specify the project name; it is a fatal error for the argument, if
given, not to match the name of one of the configured project profiles.</para>
+<para>Note: because your configuration file contains privileged
+information (the per-project Coverity authentication tokens) it should
+not have read or write permissions for anyone but its owner set. When
+<application>coverity-submit</application> detects such insecure
+permissions, it will fix them (telling you it is doing so).</para>
+
<para>The <option>-n</option> option says to display all the commands that
would be run without actually executing them. The <option>-v</option> option
enables slightly more verbose progress messages, and copies the Coverity