summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorMartin Schulze <joey@finlandia.infodrom.north.de>2002-03-04 18:50:02 +0100
committerMattia Rizzolo <mattia@mapreri.org>2014-10-03 14:05:00 +0000
commit8b372c9248930ae29763202121434d3d676d0f30 (patch)
treee0c052af107a86192d8b261adbb3e8bba8351c84 /frontend
parent2d113e8792747151bf5d830f1a1485f2f951f940 (diff)
Imported Debian patch 0.50-5.1debian/0.50-5.1
Diffstat (limited to 'frontend')
-rw-r--r--frontend/xsane-back-gtk.c2
-rw-r--r--frontend/xsane.c35
-rw-r--r--frontend/xsane.h4
3 files changed, 40 insertions, 1 deletions
diff --git a/frontend/xsane-back-gtk.c b/frontend/xsane-back-gtk.c
index 8bde762..b77b585 100644
--- a/frontend/xsane-back-gtk.c
+++ b/frontend/xsane-back-gtk.c
@@ -110,7 +110,7 @@ int xsane_back_gtk_make_path(size_t buf_size, char *buf,
}
else /* make path to temporary file */
{
- snprintf(buf, buf_size, "%s", PATH_SANE_TMP);
+ snprintf(buf, buf_size, "%s", path_sane_tmp);
}
len = strlen(buf);
diff --git a/frontend/xsane.c b/frontend/xsane.c
index 6302168..89a54a0 100644
--- a/frontend/xsane.c
+++ b/frontend/xsane.c
@@ -44,6 +44,11 @@
/* ---------------------------------------------------------------------------------------------------------------------- */
+char *path_sane_tmp = NULL;
+extern int errno;
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
struct option long_options[] =
{
{"help", no_argument, 0, 'h'},
@@ -4685,9 +4690,39 @@ void xsane_interface(int argc, char **argv)
int main(int argc, char **argv)
{
+ int len;
+ char *login;
+ struct stat st;
+
dialog = 0;
memset(&xsane, 0, sizeof(xsane)); /* set all values in xsane to 0 */
+ /* Create directory PATH_SANE_TMP/xsane-$uid */
+ login = getlogin ();
+ if (login == NULL) {
+ if ((login = (char *)malloc (10)) == NULL)
+ return 1;
+ snprintf (login, 10, "%d", getuid ());
+ }
+
+ len = strlen (login) + strlen (PATH_SANE_TMP) + 8;
+ if ((path_sane_tmp = (char *)malloc (len)) == NULL)
+ return 1;
+ sprintf (path_sane_tmp, "%s/xsane-%s", PATH_SANE_TMP, login);
+
+ if (lstat (path_sane_tmp, &st)) {
+ if (errno == ENOENT) {
+ if (mkdir (path_sane_tmp, 0700))
+ return 1; /* Can't create dir, huh? */
+ } else
+ return 1; /* Can't stat, huh? */
+ } else {
+ if (st.st_uid != getuid()) {
+ fprintf (stderr, "%s not owned by you, security problem?\n", path_sane_tmp);
+ return 1;
+ }
+ }
+
umask(XSANE_DEFAULT_UMASK); /* define permissions of new files */
xsane.sensitivity = TRUE;
diff --git a/frontend/xsane.h b/frontend/xsane.h
index 69e6d2c..ad82912 100644
--- a/frontend/xsane.h
+++ b/frontend/xsane.h
@@ -144,6 +144,10 @@ extern int xsane_scanmode_number[];
/* ---------------------------------------------------------------------------------------------------------------------- */
+extern char *path_sane_tmp;
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
#ifndef PATH_MAX
# define PATH_MAX 1024
#endif