Mojolicious as a non-HTTP server

91 views
Skip to first unread message

Brian Shaw

unread,
Jul 4, 2016, 8:45:49 PM7/4/16
to Mojolicious
Is is possible to use Mojolicious for protocols other than HTTP(S)?  I'd like to create a full end to end mail server,  The web interface is easy but, I haven't been able to figure out how to accept new mail via SMTP.

Any suggestions would be appreciated.

Brian

Dan Book

unread,
Jul 4, 2016, 10:24:45 PM7/4/16
to mojol...@googlegroups.com
Sure, Mojo::IOLoop::Server can be used for any TCP based protocol. You'll have to implement a lot yourself of course.

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Charlie Brady

unread,
Jul 5, 2016, 5:08:27 PM7/5/16
to mojol...@googlegroups.com

On Mon, 4 Jul 2016, Dan Book wrote:

> Sure, Mojo::IOLoop::Server can be used for any TCP based protocol. You'll
> have to implement a lot yourself of course.

But for SMTP you could use qpsmtpd to prove the bulk of the code.

Charlie Brady

unread,
Jul 5, 2016, 5:29:57 PM7/5/16
to mojol...@googlegroups.com
s/prove/provide/.


Brian Shaw

unread,
Jul 9, 2016, 7:20:22 PM7/9/16
to Mojolicious
Thanks for the tips guys.

Dan, do you have any examples of using Mojo::IOLoop::Server with a low (< 1024) port?

Dan Book

unread,
Jul 9, 2016, 10:53:51 PM7/9/16
to mojol...@googlegroups.com
To do this you need to start the service as root (or more generically, a user with the appropriate privileges) to bind to the port. If it has workers they can run under an unprivileged user after binding and being forked, as https://metacpan.org/pod/Mojolicious::Plugin::SetUserGroup helps you do for Mojolicious applications, similar to how preforking web servers like nginx operate.

On Sat, Jul 9, 2016 at 7:20 PM, Brian Shaw <bs...@vsvinc.com> wrote:
Thanks for the tips guys.

Dan, do you have any examples of using Mojo::IOLoop::Server with a low (< 1024) port?

Brian Shaw

unread,
Jul 10, 2016, 3:27:35 PM7/10/16
to Mojolicious
It took me a bit to get it to startup under root, I had been trying initially to use sudo but, that mucked up the paths horribly.  Once I switched fully to root, I was able to get the app to start and bind to the low port just fine.  From looking at ps though, it doesn't look like SetUserGroup is dropping privileges.  There is nothing in the log or STDERR output that indicates either success or failure though.

Stefan Adams

unread,
Jul 10, 2016, 3:31:48 PM7/10/16
to mojolicious

On Sun, Jul 10, 2016 at 2:27 PM, Brian Shaw <bs...@vsvinc.com> wrote:
it doesn't look like SetUserGroup is dropping privileges.  There is nothing in the log or STDERR output that indicates either success or failure though.

This isn't really helpful...  but I'm curious: have your dropped privileged processed try to do something super, like writing to a file writable only by root?

sri

unread,
Jul 10, 2016, 3:35:45 PM7/10/16
to Mojolicious
It took me a bit to get it to startup under root....

I like to use Linux capabilities instead, to allow the perl binary to bind to lower ports.

--
sebastian

Brian Shaw

unread,
Jul 10, 2016, 3:54:59 PM7/10/16
to Mojolicious
I have not tried writing to a privileged file.  I assumed that when the child process was started, it would be under the user account but, ps shows both the child and parent running as root.  I will try writing to a file owned by root and see what happens.

Dan Book

unread,
Jul 10, 2016, 4:52:42 PM7/10/16
to mojol...@googlegroups.com
SetUserGroup is a plugin for a mojolicious application running a prefork or hypnotoad server, it sets the user/group on the next tick of the ioloop.

--

Brian Shaw

unread,
Jul 10, 2016, 7:55:16 PM7/10/16
to Mojolicious
Thanks for the reminder, I had forgotten about capabilities.  Short term that works but, since in the long run, I'm hoping to have people in environments I don't control to use this app, I'm going to have to figure out SetUserGroup.

Brian Shaw

unread,
Jul 10, 2016, 8:01:37 PM7/10/16
to Mojolicious
Thanks for the explanation.  That makes sense.  I'll keep working on it.
Reply all
Reply to author
Forward
0 new messages