[<<] [<] Page 1 of 1 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
primax_scan and ordinary users
From: Marcos ####@####.#### Date: 31 Jan 2000 08:06:37 -0000 Message-Id: <38953153.C6335F73@teleline.es> Hello I have run into minor problems during the installation of primaxGUI and solved them with a couple of tricks. I would like to contribute them to this list, just in case someone finds them useful. INTRODUCTION ============ First of all, my configuration is the following: version of primax_scan: 0.91 motherboard: Iwill XA100Plus CPU: AMD K6-II 350 Mhz scanner: Primax Colorado D600 linux Mandrake 6.1, kernel 2.2.11 The following is the output of 'primax_scan -lon' Probing port 0378 SPP port present PS/2 bidirectional port present EPP 1.9 with hardware direction protocol Looks like a Primax Colorado Direct I tested primax_scan stand-alone and through Primax GUI(ver. 0.99-8). Both of them performed very well and for the first time I was able to use my scanner under Linux. However, I experienced some nuisances when trying to run them without becoming super-user. As you may imagine, I am quite reluctant of using the root account except when it's really necessary. PROBLEM ======= I compiled and installed both primax_scan and PrimaxGUI as root. The first time I tried to use primaxGUI as an ordinary user, I obtained the following error message: Error in Tcl script Error: Could not unlock IO ports. Are you superuser? Stack Trace for Error Could not unlock IO ports. Are you superuser? while executing "exec $app -lon" invoked from within ".top17.fra39.but60 invoke" ("uplevel" body line 1) invoked from within "uplevel #0 [list $w invoke]" (procedure "tkButtonUp" line 8) invoked from within "tkButtonUp .top17.fra39.but60" (command bound to event) SOLUTION ======== primax_scan refused to open the parallel port, because of insufficient privileges and this in turn caused primaxGUI to fail. The solution was to make the program owned by root and by setting the suid on. # chmod 6755 /usr/local/bin/primax_scan # ls -l /usr/local/bin/primax_scan -rwsr-sr-x 1 root root 84248 ene 29 21:38 /usr/local/bin/primax_scan This fixed one problem, but then I ran into trouble again with PrimaxGUI, running as a normal user, because the intermediate file that primaxGUI uses (/tmp/scan.tiff) is property of the user root -because of the root ownership and the setuid bit on- and as such cannot be moved or erased. Maybe the solution was within PrimaxGUI, but it seemed to me that it was easier to solve making minimal changes inside tiff_open() in primax_scan.c $ diff primax_scan.c primax_scan.c.original 34c34,36 < --- > /* Marcos */ > #include <sys/types.h> > /* fin Marcos */ 523a526,550 > /* If we are using PrimaxGUI as normal users, without root > * privileges, the file "scan.tiff" which the program uses > * as temporary storage or default filename can be already > * present and belonging to root -because of running the program > * as root or as a normal user but with primax_scan property > * of root and with the setuid bit on- producing an error. Instead > * of performing several tests, we can remove it unconditionally > * while we still have super-user privileges and force primax_scan > * to use our real identity on newly created files. */ > > unlink("scan.tiff"); /* as root */ > > /* change of identity */ > { > uid_t user; > gid_t group; > > user = getuid(); > group = getgid(); > setfsuid(user); > setfsgid(group); > } > /* now we have adopted the identity of the user > * who is effectively using the program */ > 529c556 < --- > 1340a1368 > As always, I haven't done enough testing, but I hope it adds something to the functionality of the combination of primax_scan and PrimaxGUI. Marcos Nieto e-mail: ####@####.#### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 1 [>] [>>] |