Menu

#16 Action scripting running with wrong user context (root instead of saned)

1.0
closed
nobody
None
2026-04-29
2017-02-19
No

Hi, I am using scanbd 1.4.1 as bundled with Ubuntu 16-04 LTS.

I have configured scanbd to run as saned user which works fine. Now, if saned starts a script triggered by pressing a scanner button this script is being executed as root. Which is IMO a bad idea.

First order of business: Assuming I have made a mistake configuring scanbd correctly. Please find enclosed my scanbd.conf. Any idea where else to look for configuration information that might be responsible for the observed behavior?

Thanks and sorry for bothering,

Christoph

1 Attachments

Related

Tickets: #16

Discussion

  • WilhelmM

    WilhelmM - 2017-02-20

    That shouldn't happen!

    The config looks fine.

    Please check if scanbd is running with the intended uid/gid.

     
    • Christoph Bernhardt

      This is what I can find out about euid and egid:

      PID UID USER GID GROUP COMMAND
      3467 108 saned 109 scanner /usr/sbin/scanbd -f

      My scan script starts as follows:

      myid=id
      logger -t "scanbd: $0" "Begin of $SCANBD_ACTION for device $SCANBD_DEVICE, running as $myid"

      The output from syslog is:

      Feb 19 16:29:18 scanbd: /usr/share/scanbd/scripts/scanfujitsu.script: Begin of scan for device fujitsu:ScanSnap iX500:34586, running as uid=0(root) gid=0(root) groups=0(root)

      Temporary directory created next is owned by root. So everything looks as if root is the euid for the action script.

      If there is anything else I can try, please let me know.

      Christoph

      On 20 Feb 2017, at 08:35, WilhelmM wimalopaan@users.sf.net wrote:

      That shouldn't happen!

      The config looks fine.

      Please check if scanbd is running with the intended uid/gid.

      [tickets:#16] https://sourceforge.net/p/scanbd/tickets/16/ Action scripting running with wrong user context (root instead of saned)

      Status: open
      Milestone: 1.0
      Created: Sun Feb 19, 2017 03:52 PM UTC by Christoph Bernhardt
      Last Updated: Sun Feb 19, 2017 03:52 PM UTC
      Owner: nobody
      Attachments:

      scanbd.conf https://sourceforge.net/p/scanbd/tickets/16/attachment/scanbd.conf (8.6 kB; application/octet-stream)
      Hi, I am using scanbd 1.4.1 as bundled with Ubuntu 16-04 LTS.

      I have configured scanbd to run as saned user which works fine. Now, if saned starts a script triggered by pressing a scanner button this script is being executed as root. Which is IMO a bad idea.

      First order of business: Assuming I have made a mistake configuring scanbd correctly. Please find enclosed my scanbd.conf. Any idea where else to look for configuration information that might be responsible for the observed behavior?

      Thanks and sorry for bothering,

      Christoph

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/scanbd/tickets/16/ https://sourceforge.net/p/scanbd/tickets/16/
      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/ https://sourceforge.net/auth/subscriptions/

       

      Related

      Tickets: #16

  • WilhelmM

    WilhelmM - 2017-02-22

    Please switch to the sane mailing list.

    I have to reproduce this error but actually don't have the time to do that in the next days ...

     
  • Christoph Bernhardt

    I spent some more time on this thing.

    Compiled 1.4.4 from sourceforge. I can reproduce the behavior I have described. I added some additional logging before and after the fork() right before the execle() of the script.

    Logging shows that euid and ruid are just fine. But then when the script gets exec'ed euid and ruid of the script are still both 0.

    Not good. Looks to me like some kind of kernel strangeness which I find very hard to believe in this basic functionality. Any idea how to pursue that further? Still hoping I do a stupid mistake somewhere...

    Christoph

     
  • Christoph Bernhardt

    I did some more research on this. Seems that bash is resetting the effective UID to the real UID. Since scanbd does not drop privileges completely, but only changes the effective UID, this leads to the actual action script being executed with root privileges.

    I applied some changes in dbus.c right before the exec for the script happens to setreuid the real and effective UIDs to the one configured in scanbd.conf. That seems to do the trick.

    If you are interested I can supply the details.

    I also investigated on the SEGV when a device is connected or disconnected. Will answer in the respective ticket. Would be interested to get your opinion on my reasoning.

    Christoph

     
  • WilhelmM

    WilhelmM - 2017-03-30
    • status: open --> closed
     
  • WilhelmM

    WilhelmM - 2017-03-30

    should be fixed in trunk and 1.4.6

     
  • aenam

    aenam - 2025-05-15

    I spent some more time on this thing.

    Compiled 1.4.4 from sourceforge. I can reproduce the behavior I have described. I added some additional logging before and after the delta fork() right before the execle() of the script.

     

    Last edit: aenam 2025-05-15
  • aenam

    aenam - 2025-06-12

    Looks to me like some kind of minecraft download kernel strangeness which I find very hard to believe in this basic functionality. Any idea how to pursue that further?

     

    Last edit: aenam 2025-06-12
  • carrillo

    carrillo - 2025-10-18

    I applied some changes in dbus.c right before the exec for the app script happens to setreuid the real and effective UIDs to the one configured in scanbd.conf.

     

    Last edit: carrillo 2025-10-20
  • James Carter

    James Carter - 2026-04-29

    I had a similar user context issue on a different project. For my gaming APK site, I solved it by explicitly setting the user in the script header with #!/bin/bash -u and defining UID before exec. The fork behavior you described matches what I saw. Check if bash is resetting the effective UID like Christoph mentioned. That was the culprit for me.

     

Log in to post a comment.

Auth0 Logo