|
JP1 Remotes
|
View previous topic :: View next topic |
Author |
Message |
Barf Expert
Joined: 24 Oct 2008 Posts: 1417 Location: Munich, Germany |
Posted: Sat Nov 05, 2011 4:10 am Post subject: |
|
|
On the issue of path names containing spaces (not really restricted to Linux):
I wrote a new wrapper:
Code: | #!/bin/sh
JAVA_HOME=/opt/\ a\ truly\ silly\ path\ /jre1.6.0_29
JAVA=${JAVA_HOME}/bin/java
RMHOME=/local/\ an\ even\ sillier\ path\
PROPSFILE=${HOME}/.\ if\ this\ is\ not\ sick,\ nothing\ is\
LIBRARIES=/local/\ truly\ braindamaged\ library\ path\ \
if [ `basename $0` = "rmir" ] ; then
RMIR=-ir
elif [ `basename $0` = "rmaster" ] ; then
RMIR=-rm
else
RMIR=
fi
if [ $# -eq 1 ] ; then
if [ `dirname $1` = "." ] ; then
file=`pwd`/$1
else
file=$1
fi
exec "${JAVA}" -Djava.library.path="${LIBRARIES}" -jar "${RMHOME}/RemoteMaster.jar" -h "${RMHOME}" -properties "${PROPSFILE}" ${RMIR} "$file"
fi
exec "${JAVA}" -Djava.library.path="${LIBRARIES}" -jar "${RMHOME}/RemoteMaster.jar" -h "${RMHOME}" -properties "${PROPSFILE}" ${RMIR}
|
Note the use of truly silly pathnames, not only with embedded spaces, but also with leading and trailing spaces. And everything worked! (Actually with the exception of the library path, since that has not been implemented in RemoteMaster (Greg, Graham: ask me for a patch if desired).)
However, the wrappers rmaster.sh and rmir.sh will break on pathnames with spaces.
@JD4x4: You do not need any wrapper at all, just something like
Code: | java -jar "/pathname possibly with spaces/RemoteMaster.jar" -h "/pathname possibly with spaces" |
should do the trick.
Next issue:
gfb107 wrote: | It also expects to have full read/write/execute permission to those files and directories. |
IFAIK, the only thing written under normal operation is the property file RemoteMaster.properties. This can be changed with the (undocumented?) -properties option (see my script above). Also in the Windows world it is considered a bad habit of writing to the installation directory. Putting the property file in, e.g. the users home direcory (Linux/Mac?), AppData-something (Windows) may be everything needed to make the program clean in this sense. |
|
Back to top |
|
|
vickyg2003 Site Admin
Joined: 20 Mar 2004 Posts: 7073 Location: Florida |
Posted: Sat Nov 05, 2011 4:33 am Post subject: |
|
|
Barf wrote: |
My suggestion
Quote: | can I suggest changing the order in autodetection since more people are using the serial/usb interface and the parallel seems to have issues? |
still appears to be sensible, as it will at least sometimes help some people. |
Apparently this was done in 2.02 beta and it broke autodetection completely. A little history on this. Autodection used to crash RMIR when I was using an LPT cable and the remote was not found. Since I have one of those finicky cables that makes me do all the battery tricks to get the remote to detect, this was a huge problem for me. I worked with Graham, and he fixed the crashing, and also ordered the autodetect so that it worked with my LPT JP1, my USB JP1, my Serial JP1.x and my JP1.2/3. After Greg changed the order for 2.02 beta only my serial JP1.x and my JP1.2/3 can be autodetected. Everytime I try to open autodetect, it stops at the serial interface. Do you think its detecting my widget? Whatever the reason, the new setup doesn't autodetect under windows at all for me. |
|
Back to top |
|
|
vickyg2003 Site Admin
Joined: 20 Mar 2004 Posts: 7073 Location: Florida |
Posted: Sat Nov 05, 2011 5:07 am Post subject: |
|
|
Barf wrote: |
Next issue:
gfb107 wrote: | It also expects to have full read/write/execute permission to those files and directories. |
IFAIK, the only thing written under normal operation is the property file RemoteMaster.properties. This can be changed with the (undocumented?) -properties option (see my script above). Also in the Windows world it is considered a bad habit of writing to the installation directory. Putting the property file in, e.g. the users home direcory (Linux/Mac?), AppData-something (Windows) may be everything needed to make the program clean in this sense. |
Windows Vista and Window 7 hates it if an app writes information in the "Program Files" sub folders from an app. "Program Files" is a restricted directory. Any changes to the program files directory after installation go in a hidden data stores area. A normal user can't find them, you even a reinstall can't fix them.
I normally don't recommend installing JP1 programs in the Program Files Folder simply because many of the older programs are not Windows 7 compliant and tend to store information in their home folder. |
|
Back to top |
|
|
JD4x4
Joined: 14 May 2010 Posts: 23
|
Posted: Sat Nov 05, 2011 9:41 am Post subject: |
|
|
Barf wrote: | (snip)
@JD4x4: You do not need any wrapper at all, just something like
Code: | java -jar "/pathname possibly with spaces/RemoteMaster.jar" -h "/pathname possibly with spaces" |
should do the trick. |
Using that in either terminal or the Run Application dialog does in fact launch either prog, however for some reason neither prog will exit (!?). I have to run System Monitor, where I find it's 'Waiting Channel' is 'futex_wait_queue_me' .. whatever that is, and I have to end the process from there. (Ubuntu 11.04 AMD 64bit)
Your message got me thinking about quotes in the shell command line however, and in my rush to get running I must not have tried one combination- the one that works!
Here is how I changed the last lines in each .sh file, and they now work with my path that has spaces:
rmir.sh -
gksudo "java -Djava.library.path='$path' -jar '$path/RemoteMaster.jar' -h '$path' -ir"
rmaster.sh-
gksudo "java -Djava.library.path='$path' -jar '$path/RemoteMaster.jar' -h '$path' -rm"
Note the addition of single quotes in each, and in the case of rmaster.sh the addition of -rm, which was missing and why I always got RM IR.
I'll get the hang of Linux yet. I'm NOT going back to M$. Thanks everyone for bearing with me on this. |
|
Back to top |
|
|
Barf Expert
Joined: 24 Oct 2008 Posts: 1417 Location: Munich, Germany |
Posted: Sat Nov 05, 2011 10:11 am Post subject: |
|
|
JD4x4 wrote: | ...however for some reason neither prog will exit (!?). I have to run System Monitor, where I find it's 'Waiting Channel' is 'futex_wait_queue_me' .. whatever that is, and I have to end the process from there. (Ubuntu 11.04 AMD 64bit) |
This bug?. Try adding Code: | -properties /tmp/remotemaster.properties | to the command line.
Quote: | I'll get the hang of Linux yet. I'm NOT going back to M$. Thanks everyone for bearing with me on this. | |
|
Back to top |
|
|
gfb107 Expert
Joined: 03 Aug 2003 Posts: 3411 Location: Cary, NC |
Posted: Sat Nov 05, 2011 6:50 pm Post subject: |
|
|
See this post, which discusses some implementation details about the how the JP1 Parallel driver works under Linux. Maybe you can help find a solution that is not a sledge hammer.
One thing to keep in mind is that we are bit-banging the parallel port, not doing normal reads/writes.
Barf wrote: |
Quote: | That's why the rmir.sh and rmaster.sh scripts use gksudo |
This is a sledge hammer solution that has a number of serious disadvantages: security and portability problems. Particularly bad as it is most often not needed.
|
_________________ -- Greg
Original RemoteMaster developer
JP1 How-To's and Software Tools
The #1 Code Search FAQ and it's answer (PLEASE READ FIRST) |
|
Back to top |
|
|
Barf Expert
Joined: 24 Oct 2008 Posts: 1417 Location: Munich, Germany |
Posted: Sun Nov 06, 2011 8:21 am Post subject: |
|
|
Greg,
I looked at the sources, and as far as I can tell (I an not a device driver expert) there is probably not a chance to have that code run without root privileges. Possibly using the standard lp driver there is hope, I do not know. What I CAN offer you is this patch:
Code: | *** jp1parallel.cpp Sun Nov 6 13:52:13 2011
--- jp1parallel.cpp~ Fri Mar 27 03:49:02 2009
***************
*** 436,444 ****
#endif
#ifdef __linux
! int success = ioperm( lp_baseport, 2, 1 );
! if (success == -1)
! return false;
#endif
if ( remoteif_check())
--- 436,442 ----
#endif
#ifdef __linux
! ioperm( lp_baseport, 2, 1 );
#endif
if ( remoteif_check())
|
It makes jp1parallel fail instead of crashing if run without privileges, thus solving the case I wrote about in a previous posting. (I have tested.)
So my suggestion is this: Take out gksudo (the standard name, as used by e.g. Suse, however is "sudo"). Verbally tell the parallel port users that they have to run as root, and must be aware of, and accept, the security implications. |
|
Back to top |
|
|
eferz Expert
Joined: 03 Jun 2010 Posts: 1078 Location: Austin, Texas |
Posted: Sun Nov 06, 2011 5:51 pm Post subject: |
|
|
gfb107 wrote: | One thing to keep in mind is that we are bit-banging the parallel port, not doing normal reads/writes. |
You get me so hot and bothered when you write things like this. _________________ Remotes; JP1.2: Comcast URC-1067, JP1.3: Insignia NS-RC02U-10A, JP1.4 OARI06G, JP2.1: Cox URC-8820-MOTO (still trying to figure out how to make them self-aware.) |
|
Back to top |
|
|
Dilligaf
Joined: 05 Aug 2003 Posts: 79 Location: Michigan |
Posted: Sun Nov 06, 2011 8:17 pm Post subject: |
|
|
what if you give lpt privileges to the program. It's been a while since I played with linux.
Mike |
|
Back to top |
|
|
Barf Expert
Joined: 24 Oct 2008 Posts: 1417 Location: Munich, Germany |
Posted: Mon Nov 07, 2011 1:37 pm Post subject: |
|
|
Dilligaf wrote: | what if you give lpt privileges to the program. |
What I did in my "code review" was to rule out possibilities of that sort. More verbosely: The code does not use a particular driver, like lp or lpt, not does it access a file or device normally only readable with privileges. Instead it "bit-bangs" bytes into raw io-locations, in a very low-level way, for example (probably?) not existing outside an x86-architecture, which the system refuses unless root, for a good reason. See the man page of ioperm.
BTW, giving privileges to a Java program definitely can be done, but is a bit more complicated... |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|