update bind via net::dns

2010-08-31 Thread Andreas Moroder

Hello,

I would like to update the bind nameserver via a perl script.
Named is running on the same machine I start the script.
I copied the key from

named.conf
key DHCP_UPDATER {
  algorithm HMAC-MD5.SIG-ALG.REG.INT;
  secret mykeyishere;
};

inserted it into my script and run it.
I always get
Update error code: REFUSED

Can anyone please tell me what is wrong with this script ?

Thanks
Andreas

# ---

use Net::DNS;

$key_name = tsig-key;
$key  = 'mykeyishere';
$tsig = Net::DNS::RR-new($key_name TSIG $key);

#$tsig-fudge(60);


$update = new Net::DNS::Update('sb-brixen.it');
$update-push(update = rr_add('testserver.sb-brixen.it A 10.53.4.2'));

$update-sign_tsig($key_name, $key);

$res = new Net::DNS::Resolver;

$reply = $res-send($update);

$reply || die (Update failed:  . $res-errorstring);

if ($reply-header-rcode eq NOERROR) {
print Update successful\n;
} else {
print Update error code:  . $reply-header-rcode . \n;
}


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: update bind via net::dns ( NOT resolved )

2010-08-31 Thread Andreas Moroder

Hello,

I made the following modification to the script

$res = new Net::DNS::Resolver(nameservers = [qw(127.0.0.1)]);

and now I get

Update error code: NOTAUTH.

This now looks really like a authorization problem, but, as I wrote, I 
got the key from named.conf.


Bye
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




get acl's of directory

2010-04-27 Thread Andreas Moroder

Hello,

is it possible to get the acl entrie of a directory on linux with perl ?

Thanks
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




get path to linked directory

2010-04-27 Thread Andreas Moroder

Hello,

I have a entry in my directory that is a soft-link to another directory.
Is there a way in perl to get, starting from the link, the path of the 
real directory ?


Thanks
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: get acl's of directory

2010-04-27 Thread Andreas Moroder

Andreas Moroder schrieb:

Hello,

is it possible to get the acl entrie of a directory on linux with perl ?

Thanks
Andreas



Hello,

probably I have found the module I need, it is File-ExtAttr
but I when i start perl Makefile.pl I get this error
Can't build and link to 'attr'

Does anyone know what causes this error ?

Thanks
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




perl, ldap list of mmebers of a group

2010-01-22 Thread Andreas Moroder

Hello,

I would like to get a list of the memberUids from a openldap group.
I tried with the script above, but even if I have 3 members I get as 
count only 1 and the results contains a single string with all 3 members.


Can anyone please help me.

Thank you
Andreas


use Net::LDAP qw(:all);
use Net::LDAP::LDIF;

use DBI;# Load the DBI module
use FindBin '$Bin';


##
## set variables
##



$port = getservbyname(ldap,tcp) || 389;


##
## make the connection, bind, and search
##
my $rootdn   = uid=admin,dc=sb-brixen,dc=it;
my $rootpw   = *;
$scope = sub;

$conn = new Net::LDAP('titan', port=$port) || die unable to connect: 
$...@\n;


$conn-bind(dn = $rootdn, password = $rootpw) || die unable to 
bind: $...@\n;


my $filtergrp = '(memberUid=*)';

$basedn = cn=trust-me-rdp-spx,ou=groups,dc=sb-brixen,dc=it;
$searchobj = $conn-search(base=$basedn, scope=$scope, 
filter=$filtergrp,attrs = ['memberUid']);


my $entry;

my $max = $searchobj-count;
print $max,\n;
  for($i = 0 ; $i  $max ; $i++) {
$entry = $searchobj-entry($i);
print $entry-get_value('memberUid'),'\n';
  }


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl, ldap list of mmebers of a group

2010-01-22 Thread Andreas Moroder

Andreas Moroder schrieb:

Hello,

I would like to get a list of the memberUids from a openldap group.
I tried with the script above, but even if I have 3 members I get as 
count only 1 and the results contains a single string with all 3 members.


Can anyone please help me.

Thank you
Andreas


Hello,

I found the solution.

@werte =$entry-get_value('memberUid');

where @werte contains all the attributes

Bye
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: paths that work in windows and linux + Umlaute

2010-01-06 Thread Andreas Moroder

  JWK 5) It is Perl4 code from 8 years ago.

that code is an abomination. one quick bug is the GetDir recursive
descent sub to get all dirs doesn't check for symlinks so it can easily
fall into an infinite recursion. the abuse of undef() is beyond bad nor
needed. and as john said, it is perl4 code which means it is about 15
years old. it should never be installed or used anywhere. also it says
it is for winblows activestate perl so it would never be easily ported
to unix as it assumes \ everywhere for dir separators. also most/all of it
is available in portable modules on cpan. it seems to more interested in
integrating into some winblows gui toy than doing real work.

so if you want to learn good perl code, look at that and see what really
BAD perl code is like. especially bad perl4 code.

uri


Hello,

I did not ask because I want to learn perl, but because I need the 
functionality of this application. I did not find anything else that 
does a similar job.


Bye and thank you
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: paths that work in windows and linux + Umlaute

2010-01-06 Thread Andreas Moroder

  AM I did not ask because I want to learn perl, but because I need the
  AM functionality of this application. I did not find anything else that
  AM does a similar job.

then why did you ask here, on a list aimed at teaching perl to
beginners? this is not the place to ask for help on how to fix horrible
old perl4 code. and you don't seem to get it, that code is nasty and
bugridden. you haven't even tried to write your own modern code for
it. most of it (from my painful but fast scan) can be done with a few
common cpan modules.

uri


Hello,

my answer was not clear.
Sure I want to lern pearl, ( I already wrote a few small scripts ).
I did not understand that the code is so bad so I tried to clean it up a 
little bit to get the work done.
Now you say that this could be done with a few cpan modules. Here my 
begginers question: could you please tell me what are the right modules 
to use ?


Sorry and thank you
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




paths that work in windows and linux + Umlaute

2010-01-05 Thread Andreas Moroder

Hello,

I have found a nice utility
http://www.novell.com/communities/node/389/adm+file+utilities+2+5
that has two problems:

1) It creates directories and files but it uses the \ backslash so it 
does not work on a linux machine.


Is there a constant or a function that give back the right character ( / 
for linux, \ for windows console ) ?


2) It does ignore Umlaute ( special german characters )

is there a clean way in perl to convert all the umlaute to ascii 
standard characters while reading from a file or as in this case in a 
array ?


The script reads in the file once
open(ADMFILE,$admFile);
@all=ADMFILE;
close(ADMFILE);


foreach(@all) {
.

Thanks
Andreas



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




tabular printing

2009-10-05 Thread Andreas Moroder

Hello,

I want pro print to screen two strings. The problem ist that the length 
of the strings are variable, so I get a unreadable output. Even using \t 
does not help because the lenght can vary from 5 to 15 characters.

Is there a simple way to expand the first columnt to a fixex size.

Thanks
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: tabular printing

2009-10-05 Thread Andreas Moroder

Алексеев Александр schrieb:

$ perl
printf %15s %15s\n, hello, world;
^D
 hello   world

--
Alexandr A Alexeev


Hello Alexander,

thanks you for the hint.

%s-15 with the - is what I searched for.

Thanks
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




get list of files sorted by date

2009-09-29 Thread Andreas Moroder

Hello,

according to the man glob can only sort by name. Is there a way to get a 
list of files sorted by date ?


Bye
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




imap module

2009-06-24 Thread Andreas Moroder

Hello,

does a IMAP library exist that supports this functionality:
connect to the IMAP server as administrator and create a mail with a 
attachment in the drafts folder of a specified user.


I searched cpan, but from the documentation I dit not find out if the 
libraries does what I want.


Thanks
Andreas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




create a tree of a configuration file content

2008-12-01 Thread Andreas Moroder

Hello,

I would like to parse ms .adm files. This files have a tree structure 
that look like


Category Name1
  category Name2
categor Name3
  Policy pol1
data lines here
...
  End policy
  Policy pol2
data lines here
...
  End policy
end category
category Name4
.

Is there a easy way to load this files as create a tree of the content 
of this type of file ? I need it to extract single policies including 
the category names they are embedded in.

The content of the single policies can be one object and must not be split.


Thanks
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




get list of accessible directories

2008-10-23 Thread Andreas Moroder

Hello,

on our linux system I have a script that runs as root that should return 
a list of subdirectorys a specific user can access.


I have the four directories and aside the users that can access them

dira   ( usera,userb, userc)
dirb   ( userb )
dirc   ( userc )
dird   ( usera, userc )

When I call the function with parameter 'usera'
the function should return

dira
dird

This script returns such a list, but only when called as a specific user

my $erg;
$pfad = '/data01/abteilungen';
@fileliste = $pfad/*;
foreach $filename (@fileliste) {
opendir(DIR,$filename);
if ($!==0 ) {
print $filename,\n;
}
closedir(DIR);
$!=0;
}

Is there a way in perl to impersonate another user in a script ?

If not, is there a function similar to system that also changes user 
while running the script passed as parameter or

is it necessary to call

@args = (su, -, $username,myscript.pl);

system @ args;

Thanks
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




store more values in a hash array

2007-08-27 Thread Andreas Moroder

Hello,

I have to store more then one value in a hash array. I tried to store a 
array as value in the hash. But when I try to retriev it I don't get the 
array I have stroed.


Can anyone please help me.

Thanks
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




compare two arrays

2007-06-20 Thread Andreas Moroder

Hello,

I have two arrays with strings and I have to find out the differences 
between this arrays. Is a perl function available that does this ?


Thanks
andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




php to perl translation

2007-06-18 Thread Andreas Moroder

Hello,

after a long search I found a script that creates oracle password 
hashes. I need the result of this script to store the password in out 
LDAP database in the oracle hashed format. The problem is that it is a 
php script and I need it in perl.


I am a perl beginner and I am not able to convert this script to perl.
Is anyone outthere that could help me ?

Passing user=scott and password=tiger

the result of the function should be.

F894844C34402B67

The mcrypt functions should be used.

Thank you very much
Andreas



?php
$username = scott;
$password = tiger;

// Using thirdparty library for DES with CBC encryption
echo get_oracle_hash($username, $password, $use_mcrypt=false);

echo br/;

// Using built-in mcrypt library for encryption
echo get_oracle_hash($username, $password, $use_mcrypt=true);





/*
ORACLE HASH ALGORITHM
1. Concatenate the username and the password to produce a plaintext string;

2. Convert the plaintext string to uppercase characters;

3. Convert the plaintext string to multi-byte storage format; ASCII
   characters have the high byte set to 0x00;

4. Encrypt the plaintext string (padded with 0s if necessary to the
   next even block length) using the DES algorithm in cipher block
   chaining (CBC) mode with a fixed key value of 0x0123456789ABCDEF;

5. Encrypt the plaintext string again with DES-CBC, but using the
   last block of the output of the previous step (ignoring parity
   bits) as the encryption key. The last block of the output is
   converted into a printable string to produce the password hash
   value.
*/
// $username: The user name
// $password: The password for the user
// $use_mcrypt: If we want to use built in library mcrypt (need to set 
server php settings)

function get_oracle_hash($username, $password, $use_mcrypt=true)
{
// Want to use mcrypt
if ($use_mcrypt)
{
// Values if we want to use mcrypt library
$chiper = MCRYPT_3DES;
$mode = MCRYPT_MODE_CBC;
}
// Want to use thirdparty library
else
{
require_once(DesCbc.php);
}

// The data we want to encrypt/make hash of
// We have to convert it to multibyte format
$temp_data = strtoupper($username) . strtoupper($password);
$data = ;
foreach (str_split($temp_data) as $char)
{
// High byte: 0x00, (i.e. H = 0x0048)
$temp_hex =  00 . dechex(ord($char));

// Have to handle some special characters different
if (in_array($char, str_split(æÆøØåÅ)))
{
$temp_hex = 0132;
}

// Add this character to the complete string of hex values
$data .= $temp_hex; 
}
$data = pack(H*, $data);

// Start key
$key0  = pack(H*, '0123456789ABCDEF');

// The initialization vector
$iv = null;

// First time encryption
if ($use_mcrypt)
{
$res1 =  @mcrypt_encrypt($chiper, $key0, $data, $mode, $iv);
}
else
{
$res1 = des($key0, $data, $iv);
}

// Get the last block to use as key in second encryption
$key2 = substr($res1, strlen($res1)-8, 8);

// Second time encryption
if ($use_mcrypt)
{
$res2 = @mcrypt_encrypt($chiper, $key2, $data, $mode, $iv);
}
else
{
$res2 = des($key2, $data, $iv);
}

// Then get the last block of $res2 and convert to hex
$hash = substr($res2, strlen($res2)-8, 8);
$hash = strtoupper(bin2hex($hash));

return $hash;
}
?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Convert german umlaut to ascii

2007-05-22 Thread Andreas Moroder

Thank you to all for your help.

Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Convert german umlaut to ascii

2007-05-21 Thread Andreas Moroder

Hello,

in our application I have to convert all german Umlaute in a string to a 
two char combination ä to ae, Ö to OE and so on.


Can anyone please tell me how to do this ?

Thanks
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Encryption

2007-04-30 Thread Andreas Moroder

Hello,

I got this steps from
http://www.ecuoug.org/papers/OraclePasswordAlgorithm.pdf


I'm a bit unclear about step 5, but it should be doable in Perl once
you determine the EXACT steps you need to take. Here are some tips
to maybe get you through the first four steps.
This my be far off from what Oracle needs, but it seems to work
for your first 4 steps. Some questions remain, like do you need a salt?
What do you use to convert back to plaintext hash? Base64encode?
What does ignore parity bits mean?

You may want to ask this on http://perlmonks.org, where more
saavy encryption and Oracle monks hang out.  But make sure you
can specify the EXACT steps needed. I'm sure it can be done.

To be honest, I would assume that the Oracle designers have made this
quite tricky to avoid hacking their passwords.

According to the document this is not true.


I will try your code later.

Thank you
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Encryption

2007-04-30 Thread Andreas Moroder


I'm a bit unclear about step 5, but it should be doable in Perl once
you determine the EXACT steps you need to take. Here are some tips
to maybe get you through the first four steps.
This my be far off from what Oracle needs, but it seems to work
for your first 4 steps. Some questions remain, like do you need a salt?
What do you use to convert back to plaintext hash? Base64encode?

Hello,

the hash is store d in hexadecimal format.

Bye
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Encryption

2007-04-30 Thread Andreas Moroder

Sorry,

I know I should write all in one answer ;)

I think in this place the algorithm is explained better.

http://groups.google.com/group/comp.databases.oracle/msg/83ae557a977fb6ed?hl=en

Bye
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Encryption

2007-04-27 Thread Andreas Moroder

Hello,

I have to calculate a hash of username and password in perl.
The calculation should be done this way:

1. Concatenate the username and the password to produce a plaintext string;
2. Convert the plaintext string to uppercase characters;
3. Convert the plaintext string to multi-byte storage format; ASCII 
characters have the

high byte set to 0x00;
4. Encrypt the plaintext string (padded with 0s if necessary to the next 
even block length)
using the DES algorithm in cipher block chaining (CBC) mode with a fixed 
key value of

0x0123456789ABCDEF;
5. Encrypt the plaintext string again with DES-CBC, but using the last 
block of the output
of the previous step (ignoring parity bits) as the encryption key. The 
last block of the
output is converted into a printable string to produce the password hash 
value.


Is it possible to implement this in perl ?
Is the Crypt-DES Module on CPAN the right module and how can I convert 
standard string to Multibyte storage ( UTF-16 ? )

An example ist

User: example
password: test
hash: BDA63848A8C31752

I don't need this script to hack anything, we would like to modify oru 
oracle paasword from a webfrontend.


Thanks
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Scan disk for files with certain owner

2007-02-28 Thread Andreas Moroder

Neal Clark schrieb:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I'd use some combination of File::Find with getgrgid and getpwuid  with 
the wanted callback.


#!/usr/bin/perl -w
use strict;

use File::Find;

my @directories = ('/dir1','/dir2');

find(\wanted,@directories);

sub wanted {
my ($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_);
if (!(defined(getpwuid($uid))  defined(getgrgid($gid {
print $File::Find::name . \n;
}
}

On Feb 28, 2007, at 12:12 AM, Andreas Moroder wrote:


Hello Neal,

It works like a charm.
thank you very much.

Andreas

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: perl script instead of grep

2007-01-08 Thread andreas . moroder


Hope fully this helps

### Script start

use strict;


...

Hello,

problem solved.
The script was writeen for windows with \\ in the path. It should run  
on a linux box. I replaced the \\ with // and now it works.


Is ti possible, for compatibility, to use // in windows too ?

Thanks
Andreas

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: perl script instead of grep

2007-01-08 Thread andreas . moroder

Quoting Roman [EMAIL PROTECTED]:


Hope fully this helps

### Script start

use strict;

my $process_dir =
'C:\work\_RHWork\projects\perl-beginers\directory-read\files-dir';

opendir(DIR,$process_dir) or die Can't open dir: $! \n;
my @files = readdir(DIR)  or die Can't read dir: $! \n;
closedir(DIR);

my %macPCName;

foreach my $file (@files)
{
  next if ($file eq .);
  next if ($file eq ..);
  #print File: , $file . \n;

  my @pcDetails = split/,/, $file;

  # Get the PC and the mac adderess if we can..
  if($pcDetails[0] =~ /^pc=(.+)/i)
  {
  my $pcName = $1;

  open(IN, $process_dir .'\\'. $file) or die Can't open file: $file
: error $1 \n;
  while(my $line =IN)
  {
  if($line =~ /Mac-Adresse:\s+(.+)/i)
  {
  #print Mac address: [[[ . $1 . ]]] \n;
  $macPCName{$1} = $pcName;
  }
  }
  close(IN);

  #print pcdetails: $pcDetails[0] : pc name : , $1 .\n;
  }
}

while ( my ($key, $value) = each %macPCName) {
  # print out the pc name and mac address
print $value $key\n;
 }

print Done ! \n;

exit(0);
 Script end


Cheers
Roman


Hello  Roman,

I get an error

File: PC=atlantis1,USER=rehastatpflege,OS=W2K-XP.txt
Can't open file: PC=atlantis1,USER=rehastatpflege,OS=W2K-XP.txt
: error atlantis1

Does perl try to open atlantis1 instead of the full name ?

Bye
Andreas




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: perl script instead of grep

2007-01-07 Thread Andreas Moroder

Based on your specs this should work:

perl -lne'print $ARGV =~ /^PC=([^,]+)/,  $1 if
/^Mac-Adresse:\s*([[:xdigit:]:]+)/' PC*



John

Hello John,

no, it doesn't
It returns two times the name of the pc.

Bye
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




perl script instead of grep

2007-01-05 Thread Andreas Moroder

Hello,

I have a directory with many files with names made like this two:

PC=laptop-fortbild,USER=fsigmund,OS=95-98
PC=INFO-FABIAN,USER=fsigmund,OS=W2K-XP

This text files may contain a line like this one

Mac-Adresse: 00:10:D7:09:5E:16

With grep

grep Mac-Adresse PC* | awk -F , '{print $1  $3}' | awk -F = '{print 
$2 $3}' | awk '{ print $1 $4}'


I get a result like this
INFO-FABIAN 00:30:05:84:91:EB
laptop-fortbild 00:10:D7:09:5E:16

I need a small perl script that loops all the files and searches for 
this mac adresses. In the loop I need this two variables ( PC-Name and 
MAC ). There may be files that does not contain the MAC-Adresse line.


Can anyone please help me

Thanks
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/