What replaced the pmap_set command? - rpc

Hi I am trying to set up the tiny honeypot on my laptop. I'm at the part of the process where you install fake service translations. The command calls for pmap_set. After portmap was replaced with rpcbind, what took its place? As in, how do I use the equivalent with rpc (library routines for remote procedure calls)? I'm trying to change the rpcinfo output I believe.

Related

How to run application on linux in the background but leave possibility to interact with it?

Requirements:
I want to run my application on linux in the background (at startup of course).
I want to be able to call start/stop/restart commands directly from console (it have to be simple just like for /etc/init.d - just call simple command directly from console).
I want to be able to call status - and I want that this command will somehow get the actual status of application returned by itself. I thought that I can call some method which returns String or just use stdin to send command but when I do noup .. &, or start-stop-daemon, then the stdin is detached. Is there a simple way to attach stdin back to the application (I've seen that I can create a pipe, but this is pretty complitated). Or what is the best way to communicate with application after it is started as a daemon (I can make a socket and connect through telnet for example, but I am looking for simpler solution and possibility to do it directly from console, without starting telnet first)? Ideally it will be great to get the possibility to send any command, but simple status will be sufficient (but again - it have to communicate with the application to get that status somnehow)
I have found many different answers. Some of them says to simply use nohup and &, and some others says that nohup and & is old fashion. Some answers says to use start-stop-daemon or JSvc (for java). But it seems that none of them will suffice this 3 requirements from me.
So... What are the simplest possibilities for all of 3 requirements to be met?
PS. I don't want to use screen. The application must be run as a linux daemon.
PPS. Application is written in Java but I am looking for generic soluction which is not limited to java.
You should create a command line tool for communicate with a daemon in way you need. The tool itself can use TCP/IP or named pipes.
And then use cli-tool start|stop|restart|status from console.
If you need to start a daemon at startup sequence (before user login) you have to deal with init system (init.d, systemd, OpenRC, etc...).
Dragons be here:
Be sure that init doesn't restart your daemon after manual stop via cli.
Command line tool itself runs with unprivileged user rights, so restart may be hard if first startup script use superuser rights or application-specific user and, especially in case deep init integration, you might have to use sudo cli-tool start.
To avoid this one possible solution is to make wrapper daemon, that runs forever via init and control the underlying application (start-stop) with proper rights.
Cons: Develop two additional tools for a daemon.
Pros: Wrapper daemon can operate as a circuit breaker between superuser/specific user and userspace.

Linux Equivalent to Windows Service Functions?

I'm trying to find the Linux equivalent to Windows Service Functions. For example, Windows has ServiceMain for the entry point, SetServiceStatus to set a status, RegisterServiceCtrlHandler, and HandlerEx to respond to control codes such as start, pause and stop requests, etc.
I checked in W. Richard Steven's Advanced Programming in the UNIX® Environment, but I guess its a bit dated for the task. Searching for "linux service api" and "linux ipc service start stop" (and similar) are producing some http and database results, but nothing too useful.
Would anyone know the C interface for writing Linux service programs?
Linux services differ much:
You develop a script (rarely binary) to handle start/stop/status
command-line parameters (to start Your standalone Main() app/process or to do anything
else)
"registration" is done by putting that script into
/etc/rc.d/init.d/ and creating corresponding
/etc/rc.d/rc{level}.d/S{order} symbolic link(s)
there is no
out-of-the-box support/idea/paradigm of service-dependencies or
auto-restart
If You run:
/sbin/service --status-all
it'll run /etc/rc.d/init.d/ scripts with "status" parameter

Running codes from local machine on a remote linux server without loading them to the server

I have a bunch of codes written in MATLAB (file.m) that I would like to run them on a remote Debian server but because of security reasons I cannot copy the code on the server. Is there anyway I can run it on the server such that nobody can access the content of the codes? I was thinking may be by referencing them (e.g. using ssh or any other way) on local machine without loading the codes to the server I can do it but I don't know how. Thanks,
-J
What's wrong with putting the code on the server and chmoding it so others can't read it?
Some other possible suggestions depending on your requirements:
Pipe the code into a matlab process over ssh (as if you just typed it in to the interactive console). This is made much harder because matlab doesn't let you define functions at the command line.
Mount your desktop using sshfs and run it from matlab that way.
If you have the fancy version of the parallel computing stuff, you can start a Matlab worker process on the server and send code to it remotely, I think.
If you want to protect the sourcecode of your .m files, you can scramble them with pcode. That way matlab will be able to execute them, but the original .m file can't be reconstructed, although bad people can still steal your .p code and execute (but not modify) it.
I don't know what kind of security you have in mind. Executing code on a server without actually transmitting the code to it sounds impossible to me. If you don't trust the remote server, you'll have to execute in on your own machine and have the server send you the data that has to be processed.
Have a look at fuse.

Run command when connected to a specific wireless network

In my university there's a certain wlan network open for the students and employees. To use it, however, one must first log in via a website using your own username and password. This can also be done by submitting a http request with the right POST-data to the same website. I already have a shell script that does this but I'm still curious to whether it would be possible to have this script run automagically every time my computer connects to the university wlan. Is it possible to do this in some semi-easy way?
I know that NetworkManager (which is used in Ubuntu) exposes a DBUS interface -- I would suspect there is an event for network connected / disconnected which you could use. Try checking the NetworkManager DBUS Interface spec.
If you've never worked with DBUS before, fear not, there are bindings for pretty much every language. I'm sure there's even a CLI client you could invoke from a shell script. This blog entry shows how to detect a new connection from NetworkManager with Python -- it might be a good starting point
You might write a simple script that runs "iwconfig" and processes it's output. If the name of the network is found (with Regex for example) you send a request.
I don't think you can trigger the script when you are acutally connected to the network, but you can add it to CRON, so it is executed for example every ten seconds.
Heres's a document you may find helpful: https://help.ubuntu.com/community/CronHowto

Automated deployment of files to multiple Macs

We have a set of Mac machines (mostly PPC) that are used for running Java applications for experiments. The applications consist of folders with a bunch of jar files, some documentation, and some shell scripts.
I'd like to be able to push out new version of our experiments to a directory on one Linux server, and then instruct the Macs to update their versions, or retrieve an entire new experiment if they don't yet have it.
../deployment/
../deployment/experiment1/
../deployment/experiment2/
and so on
I'd like to come up with a way to automate the update process. The Macs are not always on, and they have their IP addresses assigned by DHCP, so the server (which has a domain name) can't contact them directly. I imagine that I would need some sort of daemon running full-time on the Macs, pinging the server every minute or so, to find out whether some "experiments have been updated" announcement has been set.
Can anyone think of an efficient way to manage this? Solutions can involve either existing Mac applications, or shell scripts that I can write.
You might have some success with a simple Subversion setup; if you have the dev tools on your farm of Macs, then they'll already have Subversion installed.
Your script is as simple as running svn up on the deployment directory as often as you want and checking your changes in to the Subversion server from your machine. You can do this without any special setup on the server.
If you don't care about history and a version control system seems too "heavy", the traditional Unix tool for this is called rsync, and there's lots of information on its website.
Perhaps you're looking for a solution that doesn't involve any polling; in that case, maybe you could have a process that runs on each Mac and registers a local network Bonjour service; DNS-SD libraries are probably available for your language of choice, and it's a pretty simple matter to get a list of active machines in this case. I wrote this script in Ruby to find local machines running SSH:
#!/usr/bin/env ruby
require 'rubygems'
require 'dnssd'
handle = DNSSD.browse('_ssh._tcp') do |reply|
puts "#{reply.name}.#{reply.domain}"
end
sleep 1
handle.stop
You can use AppleScript remotely if you turn on Remote Events on the client machines. As an example, you can control programs like iTunes remotely.
I'd suggest that you put an update script on your remote machines (AppleScript or otherwise) and then use remote AppleScript to trigger running your update script as needed.
If you update often then Jim Puls idea is a great one. If you'd rather have direct control over when the machines start looking for an update then remote AppleScript is the simplest solution I can think of.

Resources