Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mac sudo authorization help

Mac sudo authorization help

Scheduled Pinned Locked Moved General and Desktop
37 Posts 5 Posters 15.6k Views
  • 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.
  • G Offline
    G Offline
    goetz
    wrote on last edited by
    #11

    Just for the nitpicking records: Mac OS X is BSD/Darwin based, not Linux. It uses a couple of GNU software though :-)

    Now for something serious:
    Setting a file to mode 777 is a bad idea. Do not do that unless you are in need of everyone on the system changing the file's contents!

    http://www.catb.org/~esr/faqs/smart-questions.html

    1 Reply Last reply
    0
    • AlicemirrorA Offline
      AlicemirrorA Offline
      Alicemirror
      wrote on last edited by
      #12

      Hi Volker, I was just waiting you at this party :D

      [quote author="Volker" date="1316174529"]Just for the nitpicking records: Mac OS X is BSD/Darwin based, not Linux. It uses a couple of GNU software though :-)

      Now for something serious:
      Setting a file to mode 777 is a bad idea. Do not do that unless you are in need of everyone on the system changing the file's contents![/quote]

      It is all true, but what I wrote was only an exmple based on my memory and not the command to be created. I think that it can give idea of the concept.

      Then +x or 666 instead of 777 maybe a good idea. But this was and example. The concept is: create a shell program then call it from the GUI and redirect the errio or console to the GUI and see what is the return code then act consequently.

      Just to be precise: sure, Mac OSX is BSD and it is not a linux just like the debian based distributions (Meego, Harmattan, Ubuntu, Debian itself), gentoo, RedHat and many more including those like OpenWRT and Ltib especially dedicated to the embedded Linux platforms?

      Cheers.

      Enrico Miglino (aka Alicemirror)
      Balearic Dynamics
      Islas Baleares, Ibiza (Spain)
      www.balearicdynamics.com

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #13

        I know, it was just a quick example, and of course it works. But we all know, that not so experienced users may take the advice literally and end up with a, say suboptimal or dangerous setup. One should keep this always in mind, IMHO.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • AlicemirrorA Offline
          AlicemirrorA Offline
          Alicemirror
          wrote on last edited by
          #14

          Corrected the post with the example and added a short not. So the problem is solved :)

          Enrico Miglino (aka Alicemirror)
          Balearic Dynamics
          Islas Baleares, Ibiza (Spain)
          www.balearicdynamics.com

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Ketan Shah
            wrote on last edited by
            #15

            After running the script that you provided I got an error.

            "-bash: ./apachestarter.sh: /bin/bash^M: bad interpreter : No such file or directory".

            What is the solution for this?

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #16

              You should change the file to unix line endings (newlines instead of carriage return).

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • AlicemirrorA Offline
                AlicemirrorA Offline
                Alicemirror
                wrote on last edited by
                #17

                @Volker: are you sure? I exchange continuously files between mac and ubuntu and windows 7 too but the conversions is automatic. It is possible the the folder example that I have suggested can't be applied to the Mac folder structure. I have no idea where apache started is located in the Mac. But I think that Ketan should know.

                If the error is what you mean (I suspect too because of this ^M ...) it is strange that happens. Why ?

                Enrico Miglino (aka Alicemirror)
                Balearic Dynamics
                Islas Baleares, Ibiza (Spain)
                www.balearicdynamics.com

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #18

                  @alicemirror
                  It heavily depends on the editor and it's settings. The rest is guessing from the crystal ball. You're right, my guess comes from the ^M - I stumbled over that myself already.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • AlicemirrorA Offline
                    AlicemirrorA Offline
                    Alicemirror
                    wrote on last edited by
                    #19

                    @volker
                    Me too, that character worried me too. But I use Mac dayly and just when I open a windows file that for sure has a different coding for the line termination the message that I receive is a fast msgBox "converting to line termination characters" etc. then it disappear. So think we can exclude that the problem is it. I know that the Linux of Mac is different from the Linux of debian in the management of /etc/launcher shell commands. Not only, there are different apache versions. My example was regarding the apache 2 on pure debian machine (always used on servers, not on desktop machines) ...

                    Enrico Miglino (aka Alicemirror)
                    Balearic Dynamics
                    Islas Baleares, Ibiza (Spain)
                    www.balearicdynamics.com

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      Ketan Shah
                      wrote on last edited by
                      #20

                      Thanks Alicemirror and Volker, finally the script executed successfully. As Volker told to change the file to Unix line endings. I did that by removing /r from the file and after that the script executed.

                      Thanks a lot once again.

                      1 Reply Last reply
                      0
                      • AlicemirrorA Offline
                        AlicemirrorA Offline
                        Alicemirror
                        wrote on last edited by
                        #21

                        Well, the important is that this was the correct way.

                        Enrico Miglino (aka Alicemirror)
                        Balearic Dynamics
                        Islas Baleares, Ibiza (Spain)
                        www.balearicdynamics.com

                        1 Reply Last reply
                        0
                        • AlicemirrorA Offline
                          AlicemirrorA Offline
                          Alicemirror
                          wrote on last edited by
                          #22

                          Just a question [O.T.] what method have used to launch the call from inside Qt ? Please can you see few lines of code?

                          Thank you

                          Enrico Miglino (aka Alicemirror)
                          Balearic Dynamics
                          Islas Baleares, Ibiza (Spain)
                          www.balearicdynamics.com

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            Ketan Shah
                            wrote on last edited by
                            #23

                            Sorry, can you please elaborate what you are exactly asking.

                            1 Reply Last reply
                            0
                            • AlicemirrorA Offline
                              AlicemirrorA Offline
                              Alicemirror
                              wrote on last edited by
                              #24

                              You have created the shell command that is called in some conditions from inside your QT GUI, as I have understood correctly. Thus what is the code that you have used to launch the shell program from inside the application ?

                              This was my question.

                              Enrico Miglino (aka Alicemirror)
                              Balearic Dynamics
                              Islas Baleares, Ibiza (Spain)
                              www.balearicdynamics.com

                              1 Reply Last reply
                              0
                              • K Offline
                                K Offline
                                Ketan Shah
                                wrote on last edited by
                                #25

                                Your script worked, but I didnt used it completely in my Qt app.I had used the following code from your script which was very helpful,

                                @echo $PASSWORD | sudo -S /Application/apps/apache/bin/httpd@

                                Actually what I have done is I have build a dialog that will ask the current user for its password and I have stored that password in a variable. After that I have verified it by using the following code,

                                @QProcess *p = new QProcess;
                                p->start("bash", QStringList()<<"-c"<<"echo $PASSWORD | sudo -S ls /var/db/shadow/ ; echo $?");
                                p->waitForStarted(1000);
                                p->waitForFinished(1000);
                                QString readcode = p->readAll();@

                                if the command is executed successfully it will return 0 or else it will return 1.
                                So if the password is correct than I have stored it in the PASSWORD variable and after that have started apache with that password.

                                According to you would it be the right procedure to verify the sudo password?

                                1 Reply Last reply
                                0
                                • AlicemirrorA Offline
                                  AlicemirrorA Offline
                                  Alicemirror
                                  wrote on last edited by
                                  #26

                                  Yes, it is correct.
                                  Just an advice: in this way you wait for a while the process to finish. Maybe best to manage it as a signal. As a matter of fact the shell call is a secondary process launch. With an event-driven it is sure that you return from the task when the process is finished. Then setup a timer too that after a reasonable period (i.e. 30 seconds) stop the process anyway because something was wrong. This is a general consideration, not for a case so simple.
                                  Add too a Busy indicator so the user see that is waiting for the command sequence compleiton.

                                  Enrico Miglino (aka Alicemirror)
                                  Balearic Dynamics
                                  Islas Baleares, Ibiza (Spain)
                                  www.balearicdynamics.com

                                  1 Reply Last reply
                                  0
                                  • K Offline
                                    K Offline
                                    Ketan Shah
                                    wrote on last edited by
                                    #27

                                    Thanks for your advice, will surely work on it.

                                    1 Reply Last reply
                                    0
                                    • AlicemirrorA Offline
                                      AlicemirrorA Offline
                                      Alicemirror
                                      wrote on last edited by
                                      #28

                                      @Ketan: please set this thread to [Solved}. Thanks.

                                      Enrico Miglino (aka Alicemirror)
                                      Balearic Dynamics
                                      Islas Baleares, Ibiza (Spain)
                                      www.balearicdynamics.com

                                      1 Reply Last reply
                                      0
                                      • K Offline
                                        K Offline
                                        Ketan Shah
                                        wrote on last edited by
                                        #29

                                        @Alicemirror: Sorry, but how can I set this thread to solved.

                                        1 Reply Last reply
                                        0
                                        • AlicemirrorA Offline
                                          AlicemirrorA Offline
                                          Alicemirror
                                          wrote on last edited by
                                          #30

                                          :)
                                          it;s simple: go to the first post (it's your) and click edit.
                                          Correct the title writing [Solved] in front.

                                          Cheers

                                          Enrico Miglino (aka Alicemirror)
                                          Balearic Dynamics
                                          Islas Baleares, Ibiza (Spain)
                                          www.balearicdynamics.com

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved