Page 1 of 2

barriers to not using root for MX?

Posted: Thu 01 Oct 2015 9:50 pm
by GlueGuy2
We just switched our VP2 weather station monitoring over to MX, and it seems to be working well on a raspberry pi (Model B Revision 2.0).

I created a user "cumulus" to store all the MX files and data (excepting mono). I have not tried running mono/MX as that user, but thought I would canvas the collective on what the barriers are toward running MX as something other than root.

I presume the issues are with mono, and not with MX, but I really have no clue at this point. I do run other types of web server stuff on linux systems, and all of those run the web GUI (apache) as a special user apache.apache. Those all work great, so my assumption is that the issue is not with the web server, but in fact with mono, or something beyond that.

I'm thinking about this, because what I want to do is to make the pi accessible over the internet, and I'm planning on opening up a port to go through our router/firewall.

Re: barriers to not using root for MX?

Posted: Fri 02 Oct 2015 3:24 pm
by jank
GlueGuy2 wrote: I'm thinking about this, because what I want to do is to make the pi accessible over the internet, and I'm planning on opening up a port to go through our router/firewall.
Open your firewall to access the Raspberry Pi on Port 8998 ?
alternatively you can install a apache Webserver and copy the files locally instead of using the build in FTP.
In this case, you are allowing access to the apache directory and not to the Cumulus Webinterface which is only for the Admin.

Re: barriers to not using root for MX?

Posted: Sat 10 Oct 2015 10:31 am
by steve
I think the issue is with the HttpListener which MX uses for the web interface - this is the issue on Windows, and it can be run in non-admin mode by allowing access to the URL that it listens on. From what I read, on Linux it should only be an issue when trying to listen on port 80, and MX doesn't do that. Have you tried running it as non-root (making sure that all of the files and directories have the necessary permissions for your user)?

Note that if you allow access to the MX user interface over the internet, you will also be allowing access to the configuration interface.

Re: barriers to not using root for MX?

Posted: Sun 11 Oct 2015 8:44 pm
by WetCoast
I just tried running CumulusMX.exe as a 'regular' user and it seems to run but says it can't find my weather station.

gord@server:~/Cumulus$ mono CumulusMX.exe -lang en-CA
Current culture: English (Canada)
Serial: CF1E8C14E54505F60AA10CEB8D5D8AB3
Cumulus MX v.3.0.0 build 3031
This is pre-release beta software
Today.ini = data/today.ini
Last update=2015-10-11T12:10:00
Fine Offset station not found
Cumulus running at: http://*:8998/
(Replace * with any IP address on this machine, or localhost)
Starting web socket server on port 8002
2015-10-11 1:38:28 PM
Type Ctrl-C to terminate

I'm not at all sure how it communicates with the weather station (that's connected via USB) perhaps there is something I could do to allow this??

Re: barriers to not using root for MX?

Posted: Mon 12 Oct 2015 7:19 am
by steve
You need to change the permissions on the device so that it can be accessed from non-root. Create a file called 99-hid.rules and put it into /etc/udev/rules.d/

The file should contain the following line:

KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="1941", ATTRS{idProduct}=="8021", MODE="0666"

(The vendor and product IDs shown are correct for Fine Offset stations only).

Then unplug your station, plug it in again, and start MX.

Re: barriers to not using root for MX?

Posted: Mon 12 Oct 2015 8:36 pm
by WetCoast
wow Steve, you opened a whole new area for me! I never knew much about udev and now I know just enough to be dangerous. Well not too dangerous because I still don't understand much.

One thing I found when researching this udev stuff was the following:
Files in /etc/udev/rules.d/ are parsed in lexical order, and in some circumstances, the order in which rules are parsed is important. In general, you want your own rules to be parsed before the defaults, so I suggest you create a file at /etc/udev/rules.d/10-local.rules and write all your rules into this file. from (http://www.reactivated.net/writing_udev_rules.html)

I'm not at all sure the implications of timing of when the rules are run or, in our case, if it really makes any difference.
Do you have an opinion?

Re: barriers to not using root for MX?

Posted: Mon 12 Oct 2015 8:44 pm
by steve
Everywhere that I have seen instructions for changing the permissions on HID devices, they have used 99- as the start of the rules file.

Re: barriers to not using root for MX?

Posted: Tue 13 Oct 2015 10:49 am
by mcrossley
Makes sense as you want your rules to over-ride the defaults, so they need to be processed last.

Re: barriers to not using root for MX?

Posted: Wed 14 Oct 2015 4:51 pm
by WetCoast
I agree.
I've added what you suggested and now I can run CumulusMX as a non-root user.

Thanks!

Re: barriers to not using root for MX?

Posted: Wed 02 Dec 2015 5:26 pm
by richard_newberry
I have done what Steve suggested it doesn't work for me. I have rebooted the vmware host and removed the USB and re added it back but still only works with root by doing su within user cumulus.

Re: barriers to not using root for MX?

Posted: Wed 02 Dec 2015 5:48 pm
by steve
More details, please - "doesn't work" is not helpful. What happens when you run it non-root? Are all of your file and directory permissions set correctly for the non-root user that you're using?

Re: barriers to not using root for MX?

Posted: Thu 03 Dec 2015 2:23 pm
by richard_newberry
Sorry Steve,

I was on about the script called ./cumulusmx.sh only works with root or sudo.

Yes cumulus does work with mono CumulusMX.exe however using a ftp server on my machine. the ftp only accepts root access trying to find a way of using cumulus as a user to only use the ftp server on the machine cumulus is installed on.

Re: barriers to not using root for MX?

Posted: Thu 03 Dec 2015 2:32 pm
by mcrossley
Why would you FTP to same machine, a simple copy would be more reliable and efficient?

Re: barriers to not using root for MX?

Posted: Fri 04 Dec 2015 9:05 am
by richard_newberry
If i dont use FTP how can i upload updated data which updates every minute to the /var/www without using a FTP client?

Re: barriers to not using root for MX?

Posted: Fri 04 Dec 2015 9:51 am
by water01
If it on the same machine just use Cumulus to copy the files to the /var/www directory.