Is there a Linux equivalent for the Windows InetIsOffline function? - linux

Is there a Linux function that is equivalent to the InetIsOffline function in Windows (provided by url.dll) that can tell me whether the system is connected to the Internet, or do I have to cook up something myself?
The reason I ask is that I am an early-adopter of Lhogho. I found out how to do this in Windows and wanted to develop something to offer the same functionality in Linux.

You can talk to Network Manager over D-Bus to see if anything is connected, but other than that there's no specific way of doing so. And even NM isn't always accurate.

You could also parse some file under /proc/net/ such as /proc/net/if_inet6 or /proc/net/tcp
But why do you want to do that? If you want to check that some site is accessible, just access it programmatically (e.g. with libcurl).
And it does happen that some sites are inaccessible and others still work.

It might mean "do I have a default route?", or at least that would be a reasonable implementation, IMHO. So, just check the routing table (/proc/net/route) for it :).
That of course will not work with IPv6 (you would need to parse ipv6_route), but it's complicated to decide how that should be treated. Maybe Wine source code, or MSDN documentation can shed light on the matter.

Related

Linux weird Folder Permission needed (CentOs)

I don't know if what I am asking now is possible, but if it is, that would be great.
I have a public folder where some users have access. I want to prevent all these users from creating subfolders into it. They should be able to create files like touch note.txt but not being able to create other folders.
I was thinking if I could disable mkdir command locally for the folder would do, but I don't know even if its possible.
First, this is not an programming question - so http://superuser.com is the better place to ask.
AFAIK (i'm not an Centos guru) - it is not possible to do with CentOS. For this type of permissions you need OS what supporting extended ACL. For example: Solaris ZFS, or Mac OS X and so on. Changing the underlaying OS is probably not a solution for you, so here is one another possibility - but not easy.
You can use FUSE and make a program what will act as filesystem bridge and simple would not allow creating directories. As I told - not a trivial solution, but possible. For the low volume usage you can use perl for implementing filesystems in perl, through the FUSE kernel/lib interface. See Fuse. For some basic tutorial you can check this site.
Sounds silly? Yes, it is. Maybe someone know an easy way setting up ACL on Centos. At least it is an "programmming solution". :).
In principle, SELinux should allow that level of control, but don't ask me how to configure it.

Friendly server hack attempt (to determine vulnerabilities)

I own a Linux VPS, which I use mostly for fun (to teach myself things etc.), while I also have some rather important services there, such as an email stack, a Jabber server, a LAMP stack etc.
I was thinking of an online service, which I could submit my server's IP address to, and the experienced people there could check my box for any vulnerabilities, just for fun, while me having some degree of confidence that they won't actually compromise the box.
Are you aware of anything like that?
I know what nmap is, so don't suggest that.
You might want to check out Sitewatch, they have a free service.

Sandboxing a program using WinAPI hooks

I'd like to sandbox a native code and use hooking of WinAPI and system functions to block or allow this program to perform some operations like reading/writing files, modify Windows registry, using an Internet connection. Is it a good and secure way to do so? How difficult would it be for that program to bypass such a security layer?
I've checked your questions and they all are related to the task that seems to be invalid from the very beginning, and here's why: you are trying to secure one application and you are ready to reinvent the wheel for this. There exist several approaches (and many ready-made solutions) to solve your problem. So instead of coding you need to look at existing solutions.
The approaches are:
use Windows permissions to restrict
access of your application to
resources
take take VMWare or Parallels or
other virtualization platform and
run your program there
take sandboxing SDK (such as
BoxedApp) and "wrap" your
application.
+1 to Hans, however if you are really into it then I can recommend Easyhook. I have personally used it successfully in Win XP, Vista and 7. I don't know how bypassable it is but other alternatives do exist - madSHI hooks, and, if you want to go the official way, try Detours from Microsoft.
Antivirus apps try to solve nearly the same problem, without much success.
1. You'd never know how even most common operations can be used.
2. There're syscalls, so the program doesn't have to use winapi at all.

HP LoadRunner question - content checking: web apps only

I know there some experienced loadRunner users around so I would like to ask (as I was not able to find the answer on my own): Is the content checking available only for webpages? I mean, I cannot check for content in win32 apps, right? Thank you!
If you are asking about using the web_reg_save_param function, then, yes, it is limited to web applications.
Generally, functions with a "web" prefix are unique to web applications.
web_reg_save is web protocol-only, yes.
Depending on the protocol you use, you surely have a way to do a context verification. For example, when you are using terminal emulator, you can check for specific strings in specific display areas. Or, when using Citrix, you can wait for specific bitmaps to appear in certain areas. Or, with RMI, you can inspect whatever you want in the replies you receive.
Inspecting a Win32 app's screen, however, might be painful. LoadRunner tries to "sniff" at the protocol level, so usually you'd have some traffic to emulate on the sockets level, for example. You could still find the app's window handle and fetch some content from it using Windows API calls. LR will not assist you in doing so, though, except for with DLL support.

dns for dynamic IP

I'd like to know the best solutions to get a public static dns or IP adress to access a computer on a routed network (for example to access from the internet a PC in my home LAN).
I heard about no-ip and dyndns.
Are they good? which one is the best? Is it really reliable ?
This is a server fault question, but to provide an answer anyway, I use dyndns.org, it works nicely ( most routers even have auto update support built in, and for those that dont there desktop updater works just fine. )
dyndns.org seems to have amazingly reliable uptime, and i cant talk for noip as i have never used it. give them a try and see which one you like more.
There are several free dynamic DNS services like afraid.org, dynu.com etc. You may want to go with one which has an open API so that you can use it from within your application.
May be you can have a look at https://www.good-dns.net/
Very simple to use, provides a URL for automatic IP update, so suitable for dynamic IPs.
There a lot options available - as far as I know dyn.org are not free for while already. And I am using https://myonlineportal.net
But you have to test by yourself and figure out which suit best for you. Sometimes it's just the available domain name.

Resources