-2

I want create a simple PHP form (nickname and username) to allow users register a new jabber account in the server through the website. I'm using prosody as XMPP server and I can create new accounts through clients such Pidgin, etc but although I was reading about it, I found that to use XMPP over http I should enable a bosh server but I don't know if it can help me to find a solution for my problem and the few libraries which I found of XMPP in PHP haven't any function to create new accounts in the server (or unless I didn't see any function...). And I don't want use the exec function due to that the command to register new users ask me for sudo privileges. If someone can teach me about how deal with it to learn I will be very grateful.

Kevin Gravell
  • 499
  • 2
  • 7
  • 20
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. – Charlotte Dunois Jan 17 '16 at 19:47
  • I don't want spam. I tried to explain was I was trying to resolve my problem. I want a simple form in php where any user can enter a nickname and password and register it into the xmpp server. First I tried to do it directly through exec php function, but it doesn't work due to that www-data hasn't the right privileges and I'm asking if I need enable a bosh server and, if so, how can I create a new user through the php form? I don't know if I explained me very well or not @CharlotteDunois – Kevin Gravell Jan 17 '16 at 19:53
  • Welcome to SO. Please read [What topics can I ask about](http://stackoverflow.com/help/on-topic) and [How to ask a good question](http://stackoverflow.com/help/how-to-ask) And [the perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) SO is **not a free coding or tutorial service** You have to show that you have made some effort to solve your own problem. – RiggsFolly Jan 17 '16 at 19:56
  • In fairness guys, although his question could have been put forward in a much better way, he did imply that he had already tried PHP exec(), and he asked for a specific solution to deal with his problem of "how to create a user account in Prosody via PHP." – ruhnet Jan 17 '16 at 20:04

1 Answers1

1

Although your question could have been put better, one solution would seem to be running the prosody server with a non-root account (which is probably a good idea anyway). Either with www-data or another user/group that would allow the www-data user to have enough privileges. Then PHP exec shouldn't have a problem.

Also, there used to be a module for prosody that allowed control via XMLRPC. The docs show it has been deprecated in current versions, but maybe it's still in the source? If that module is still available to use then you could use XMLRPC to speak to the prosody server from PHP.

ruhnet
  • 651
  • 1
  • 7
  • 14
  • Thanks for your reply, it is right that I didn't explain me very well... Sorry for that, it was my guilt. I saw the XMLRPC module but how it is deprecated I thought that it wasn't compatible with last versions or there is another problem... Is it safe run prosody as www-data? If that, how can I do it? Adding the following the line to my script? `www-data ALL=(ALL) NOPASSWD: /usr/bin/prosody` – Kevin Gravell Jan 17 '16 at 20:23
  • No problem, we're all learning and improving our asking skills :-) – ruhnet Jan 17 '16 at 20:32
  • Running Prosody as www-data is certainly safer than running it as root :-) As an alternative, sudo can be configured to allow certain commands without asking for a password. I'm not intimately familiar with Prosody, so I can't advise you exactly on how to run it as the user you want. I believe it depends on your distribution too, as init scripts and such vary. – ruhnet Jan 17 '16 at 20:33
  • Yes :) Okay, just one last question and I won't bother you more, how can I run prosody as www-data? Because if I execute the following command in the console: `runuser -l www-data service prosody start` I obtain `This account is currently not available.` – Kevin Gravell Jan 17 '16 at 20:37
  • Like I said how to do that depends on which distribution you are running. `runuser` fails because for security reasons you can't "log in" as www-data. – ruhnet Jan 17 '16 at 20:45
  • You would normally configure the user that prosody runs via an init script. – ruhnet Jan 17 '16 at 20:45