/*
This file is part of GNUnet.
- Copyright (C) 2006-2016 GNUnet e.V.
+ Copyright (C) 2006-2018 GNUnet e.V.
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet 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
- General Public License for more details.
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
#endif
-#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+#define LOG(kind,...) GNUNET_log_from (kind, "util-os-installation", __VA_ARGS__)
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
+#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util-os-installation", syscall, filename)
/**
.bug_email = "gnunet-developers@gnu.org",
.homepage = "http://www.gnu.org/s/gnunet/",
.config_file = "gnunet.conf",
- .user_config_file = "~/.config/gnunet.conf"
+ .user_config_file = "~/.config/gnunet.conf",
};
/**
ssize_t size;
char *lep;
- GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/exe", getpid ());
- size = readlink (fn, lnk, sizeof (lnk) - 1);
+ GNUNET_snprintf (fn,
+ sizeof (fn),
+ "/proc/%u/exe",
+ getpid ());
+ size = readlink (fn,
+ lnk,
+ sizeof (lnk) - 1);
if (size <= 0)
{
- LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "readlink", fn);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+ "readlink",
+ fn);
return NULL;
}
- GNUNET_assert (size < sizeof (lnk));
+ GNUNET_assert ( ((size_t) size) < sizeof (lnk));
lnk[size] = '\0';
while ((lnk[size] != '/') && (size > 0))
size--;
"/%s/libexec/",
current_pd->project_dirname);
/* test for being in lib/gnunet/libexec/ or lib/MULTIARCH/gnunet/libexec */
- if ( (size > strlen (lep)) &&
+ if ( (((size_t) size) > strlen (lep)) &&
(0 == strcmp (lep,
&lnk[size - strlen (lep)])) )
size -= strlen (lep) - 1;
GNUNET_free (lep);
- if ((size < 4) || (lnk[size - 4] != '/'))
+ if ( (size < 4) ||
+ (lnk[size - 4] != '/') )
{
/* not installed in "/bin/" -- binary path probably useless */
return NULL;
GNUNET_assert (0);
upath = GNUNET_malloc (u8_string_length + 1);
- memcpy (upath, u8_string, u8_string_length);
+ GNUNET_memcpy (upath, u8_string, u8_string_length);
upath[u8_string_length] = '\0';
free (u8_string);
#ifdef MINGW
char *binaryexe;
- GNUNET_asprintf (&binaryexe, "%s.exe", binary);
- if ( (GNUNET_YES == GNUNET_STRINGS_path_is_absolute (binaryexe, GNUNET_NO,
- NULL, NULL)) ||
+ GNUNET_asprintf (&binaryexe,
+ "%s.exe",
+ binary);
+ if ( (GNUNET_YES ==
+ GNUNET_STRINGS_path_is_absolute (binaryexe,
+ GNUNET_NO,
+ NULL, NULL)) ||
(0 == strncmp (binary, "./", 2)) )
p = GNUNET_strdup (binaryexe);
else
}
GNUNET_free (binaryexe);
#else
- if ( (GNUNET_YES == GNUNET_STRINGS_path_is_absolute (binary, GNUNET_NO,
- NULL, NULL)) ||
+ if ( (GNUNET_YES ==
+ GNUNET_STRINGS_path_is_absolute (binary,
+ GNUNET_NO,
+ NULL,
+ NULL)) ||
(0 == strncmp (binary, "./", 2)) )
+ {
p = GNUNET_strdup (binary);
+ }
else
{
p = get_path_from_PATH (binary);
if (NULL != p)
{
- GNUNET_asprintf (&pf, "%s/%s", p, binary);
+ GNUNET_asprintf (&pf,
+ "%s/%s",
+ p,
+ binary);
GNUNET_free (p);
p = pf;
}
binary);
return GNUNET_SYSERR;
}
- if (0 != ACCESS (p, X_OK))
+ if (0 != ACCESS (p,
+ X_OK))
{
- LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "access", p);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+ "access",
+ p);
GNUNET_free (p);
return GNUNET_SYSERR;
}
{
/* as we run as root, we don't insist on SUID */
GNUNET_free (p);
- return GNUNET_OK;
+ return GNUNET_YES;
}
#endif
- if (0 != STAT (p, &statbuf))
+ if (0 != STAT (p,
+ &statbuf))
{
- LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", p);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+ "stat",
+ p);
GNUNET_free (p);
return GNUNET_SYSERR;
}
- if (check_suid){
+ if (check_suid)
+ {
#ifndef MINGW
- if ((0 != (statbuf.st_mode & S_ISUID)) && (0 == statbuf.st_uid))
+ (void) params;
+ if ( (0 != (statbuf.st_mode & S_ISUID)) &&
+ (0 == statbuf.st_uid) )
{
GNUNET_free (p);
return GNUNET_YES;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Binary `%s' exists, but is not SUID\n"),
+ p);
/* binary exists, but not SUID */
#else
STARTUPINFO start;