• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Usage of su -m / rc.subr _user support

Scheduled Pinned Locked Moved Development
5 Posts 2 Posters 523 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    scottster
    last edited by Mar 19, 2019, 5:05 PM

    Anybody know why "Bad -c option" is triggered below? Is this an environment/shell configuration difference triggered by the usage of -m?

    From the shell in 2.4.4-RELEASE:
    su -m nobody -c 'sh -c "echo foo"'
    Bad -c option

    From a stock 11.2 FreeBSD install:
    su -m nobody -c 'sh -c "echo foo"'
    foo

    /etc/rc.subr supports providing the _user option, to allow daemons to be run as a different user, and this same error is triggered when attempting to use this.

    1 Reply Last reply Reply Quote 0
    • J
      jimp Rebel Alliance Developer Netgate
      last edited by Mar 19, 2019, 8:28 PM

      I tried it on several boxes with several different shells, and it worked for me each time. On 2.4.4, 2.5.0 snapshots, and FreeBSD 12.

      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

      Need help fast? Netgate Global Support!

      Do not Chat/PM for help!

      1 Reply Last reply Reply Quote 0
      • S
        scottster
        last edited by scottster Mar 20, 2019, 6:22 AM Mar 20, 2019, 6:16 AM

        Jim, it looks like the difference may be specific to connecting to the console using "admin" instead of "root". Connecting and issuing the prior steps as root works fine, whereas admin does not (for me).

        Admin has SHELL=/etc/rc.initial, whereas root has SHELL=/bin/sh, I haven't looked further at whether this explains the difference.

        This (rc.subr) also worked while logged in as user admin:
        _doit="echo $_doit | su -m $_user -c 'sh -s'"

        1 Reply Last reply Reply Quote 0
        • J
          jimp Rebel Alliance Developer Netgate
          last edited by Mar 20, 2019, 12:40 PM

          That would probably explain it, since admin is setup different.

          You could also install the sudo package and use that, which is less likely to care about such things.

          Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

          Need help fast? Netgate Global Support!

          Do not Chat/PM for help!

          S 1 Reply Last reply Mar 21, 2019, 8:15 PM Reply Quote 0
          • S
            scottster @jimp
            last edited by Mar 21, 2019, 8:15 PM

            This change appears to make it consistent, if you wanted it to be:
            rc.initial:
            /bin/sh -c $1
            change to
            /bin/sh -c "$1"

            1 Reply Last reply Reply Quote 0
            5 out of 5
            • First post
              5/5
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
              This community forum collects and processes your personal information.
              consent.not_received