linux

Regexp for chroot-like path building in a Linux environment

Consider the following security problem: I have a static base path (/home/username/) to which I append a user-controlled sub-path (say foo/bar.txt). The content of this file is then read and presented to the user. In the case described the full path would be: /home/username/foo/bar.txt Now to the problem. I want to control so that the...

linux iterate over files in directory

I'm trying to iterate over each file in a directory. Here's my code so far. while read inputline do input="$inputline" echo "you entered $input"; if [ -d "${input}" ] then echo "Good Job, it's a directory!" for d in $input do echo "This is $d in directory." done exit my output is always just one...

How to configure something like phpmyadmin in windows and linux?

When I visit http://domain.name/DIRECTORy,it should go to another DOCUMENT_ROOT. I'm using Apache,how to configure it correct in windows and linux respectively? ...

Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted software under Linux? I have read the work of van Doom et al., Design and implementation of signed executables for Linux, and the IBM's TL...

Unix Script not working in Java Process Runtime.exec()

Hello All... I am developing an application in Spring Web MVC where i need to execute some of the linux script.. I am using tomcat version 5.5 for running my project in linux.. My code is looking like this : Process proc = runtime.exec("sudo cp /var/tmp/mailserverfiles/editinterface.txt /etc/sysconfig/network-scripts/editinterface.tx...

Is there any difference between java run.exec of a command and shell execution?

Hi all, I have a program which calls a shell command. When I executes the command using java's run.exec, it is not working but when I executes the command directly in terminal, it works like charm. ex: pdf2swf "3bbba47.pdf" -T 9 -o "3bbba47.swf" didnt worked from java program but worked directly executing it in terminal. But when...

Anyone here has benchmarked Intel C++ compiler and GCC?

I am not sure whether I should post this question here, because this seems to be a programming-oriented website. Anyway, I think there must be some gurus here who knows this. Now I have a AMD Opteron server running CentOS 5. I want to have a compiler for a fairly large c++ Boost based program. Which compiler I should choose? ...

How to avoid FileNotFound exception when running Java on Linux because of case sensitiveness?

My web application runs on Windows. I would like to run my app on Linux also. I seem to have overcome most of the problems such as path separator, etc. Real problem now is I get FileNotFoundException when the Java code tries to open a file say Abc.txt when only abc.txt exists. :( I can't go on changing all the filenames to lowercase o...

Why doesn't JRuby script.rb > out.txt capture Java errors?

JRuby script.rb throws many Java errors. I tried outputting to a text file, but only the output from the script itself is recorded. I need to capture all the errors that happen, as they are very long. How can I do that? ...

Something wrong with my gdb or KDevelop IDE?

I have Ubuntu 9.04 and KDevelop IDE. When I am trying to debug C++ console app, it tells me: GDB cannot use the tty* or pty* devices. Check the settings on /dev/tty* and /dev/pty* As root you may need to "chmod ug+rw" tty* and pty* devices and/or add the user to the tty group using "usermod -G tty username". I installed gcc and gdb, and ...

Is this specific path concatenation in Perl code exploitable?

Assume that an attacker controls the variable $untrusted_user_supplied_path . Is the following Perl code exploitable? my $untrusted_user_supplied_path = ... if ($untrusted_user_supplied_path =~ /\.\./) { die("Tries to escape homedir."); } my $base_path = "/home/username/"; my $full_path = "${base_path}${untrusted_user_supplied_path}";...

What are often used network programming functions/code snippets?

All of us who still do some kind of network programming (TCP/UDP, DNS or Client/Server) in C repeatedly use some code snippets again and again. We do use some standard libraries but then also we do write some code very often which is not there in one library. Is there a collection of such code snippets that are used very often. If no...

Basic HTTP firewall

I am beginning work on an intelligent firewall but before I do that I need to understand clearly how a very basic firewall will work. Since me and my team is most comfortable in C we are going to use that. Could someone give example of a very basic firewall written in C. ...

svnadmin create ignoring sticky group bit on directory

I am using Subversion with Apache and want a normal user (i.e. non-root) to be able to create new repositories. I thought this would be easy enough to do using a parent directory with group www-data and the group sticky bit set. Unfortunately "svnadmin create ..." leaves only its db directory with the sticky group not set. How can I get...

Linux Pipes as Input and Output

I would like to do the following inside a C program on a Linux os: Create a PIPE using a syscall (or 2) Execute a new process using exec() Connect the process's STDIN to to the previously created pipe. Connect the process's output to another PIPE. The idea is to circumvent any drive access for performance purposes. I know that the ...

Why does Linux program that derefrences (char*)0 not always segfault?

I'm testing code that is designed to detect when a child process has segfaulted. Imagine my surprised when this code does not always segfault: #include <stdio.h> int main() { char *p = (char *)(unsigned long)0; putchar(*p); return 0; } I'm running under a Debian Linux 2.6.26 kernel; my shell is the AT&T ksh93 from the Debian k...

Non-blocking pipe using popen?

I'd like to open a pipe using popen() and have non-blocking 'read' access to it. How can I achieve this? (The examples I found were all blocking/synchronous) ...

What's the simplest way to keep track of where my program is installed?

While I'm working on it, I have my application's location hardcoded: public static string MYPROGRAM_PATH = "/path/to/my/workspace"; Obviously this won't work once I package and distribute my application. How do I keep track of where it is installed to? I'm primarily concerned with linux packaging (specifically .deb's), but I'm planni...

How to stop repeated keyPressed() / keyReleased() events in Swing

So the problem that I am having appears to be a bug that occurs only on Linux. I'm trying to have my swing app record when a key is pressed down, then to detect when that key is released. Now that shouldn't be in issue because KeyListener is supposed to handle this for me. The problem is that when I hold the key down I get lots of repea...

auto permissions on udev'd device files?

This is a dupe from SuperUser.com . Folks over there weren't smart enough or willing to help me out; maybe it's more a programmer question than an administrator one: I have an app that reads input from 4 (four) mice that are plugged in via USB in addition to the built-in touchpad. This is no problem for Ubuntu 9.10: hald notices the n...