Active Topics

 



Notices


Reply
Thread Tools
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#111
ehm... this line is ONLY for generating a RANDOM number (because $RANDOM doesn't seem to work).

it makes a copy (dd) of /dev/urandom but only of the first block (count 1) and deletes the rest (2> /dev/null).
because urandom doesn't only consists of numbers - but we want a number/integer - you have to change this using the checksum (cksum).
but this checksum is way too long so we are cutting (cut) it off. (:

i'm only searching for another way of getting randomness in my script on startup.
i tried it with rn=$(date +%S) which saves only the seconds of the current timestamp in rn... but on startup date-command only counts up and doesn't show the actual time
so i'm only getting 1 and 2... -.-

i've been searching google for the last few hours... but i can't find anything useful...

btw: i'm awake for over 40 hours... my eyes are bloody-red... so i'll go in my bed now ^^

if somebody knows a solution for getting a random number at startup... please post

good night. (:
 
tuminoid's Avatar
Posts: 188 | Thanked: 185 times | Joined on Dec 2009 @ Finland
#112
Originally Posted by b666m View Post
i tried to launch the script on shutdown with "start on shutdown" but this doesn't work.
I think it should be
Code:
start on starting shutdown
as you can see from other event.d scripts:
Code:
grep shutdown /etc/event.d/*
__________________
My wiki: User:Tuminoid
cpumem-applet: home | packages - status: 0.0.3 in Extras

cell-modem-ui: home | packages - status: 0.5.1-1 in Extras
nowplayingd: home | packages - status: 0.1-2 in extras-devel
custom-pwkmenu: home - no packages yet.
 

The Following 2 Users Say Thank You to tuminoid For This Useful Post:
Posts: 527 | Thanked: 121 times | Joined on Feb 2010
#113
Editing the first line in rvid to :

"start on starting shutdown"

made it run 3 diff. for now....

I have to go but try one more...
Look all right to me now!

Loop went like this:

1

2

5

1

2

5



Only 3 loops now

Last edited by rolan900d; 2010-02-21 at 11:06.
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#114
as far as i understand /dev/urandom gets seeded with noise from drivers during operations from the user.
so if you just startup and shutdown there are very small chances that there are any differences.

unfortunately i don't know when the entropy pool gets seeded exactly. it could be when you open any app. but it could be that it's only seeded when special things happen.

so my suggestion would be a "longer" testing of this:
1. edit /etc/event.d/rvid and change the line "start on startup" to "start on starting shutdown" and then do "chmod 777 /etc/event.d/rvid"
2. but don't startup and then shutdown your phone immediatly.
3. after startup maybe you want to open different apps. for example: surf the web with browser and things you would also do normally.
(hopefully by doing so the pool gets seeded)

if this doesn't bring any improvements i could write some additional code which saves some blocks of on shutdown /dev/urandom to a file and then seeds /dev/urandom on startup first before doing my random number generation.
(that would be a very freaky solution ^^)

one other thing you can do when you have changed to "start on starting shutdown":
open /etc/event.d/rvid and comment out the line "rn=$(dd ... )". make a new line right under this one and type "rn=$(date +%s)".
seconds since 00:00:00, Jan 1, 1970 (a GNU extension)
Note that this value is defined by the localtime system
call.
ok... it's not 100% random but hey... chances are nearly equal for all of the x.conf to get loaded.

Last edited by b666m; 2010-02-21 at 16:32.
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#115
blubb... working... the bootvideo gets set on shutdown... here's the code:

Code:
start on starting shutdown

script

  cd /etc/hildon-welcome.d/dconfs/

  if [ -f 1.conf ]; then

    # check which file is currently used
    if [ -f *.lock ]; then
      cuf=$(ls *.lock)
      ruf=$cuf
      rm *.lock
    else
      cuf="1.lock"
      ruf=$cuf
    fi

    # determine number of files in /dconfs
    nof=$(ls *.conf | wc -l)

    while [ "$ruf" = "$cuf" ]; do

      # get "random" number lol
      rn=$(date +%s)

      # in range of 1 - nof
      let "rr = $rn % $nof + 1"

      # choose random conf
      ruf="$rr.lock"
      rf="$rr.conf"
 
    done
 
    # set file for checking which file is in use
    rb="$rr.lock"
    echo "rb $rb - rf $rf"

    # copy it over to default.conf
    cp $rf ../default.conf
    touch $rb

  fi

end script
will update the instructions with a this new file. thanks for testing again!

edit: instructions and attachment on page 4 updated.
and i attached the file here too. (but you could also copy & paste the code from this post ^^)

how it works:
Attached Images
 
Attached Files
File Type: zip rvid.zip (469 Bytes, 75 views)

Last edited by b666m; 2010-02-21 at 16:59.
 
Posts: 527 | Thanked: 121 times | Joined on Feb 2010
#116
It did indeed.
I forgot to chmod 777 the file

All is good over here...

Thanx 2 Tuminoid as well

Buddy. where you have updated it?

On page 4 it is stated that the last update was done yesterday

Last edited by rolan900d; 2010-02-21 at 16:45.
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#117
i would take "rn=$(date +%s)" instead of random number generation out of /dev/urandom.

we just need something which is different every time we look at it and it don't have to be something for strong cryptography. (:
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#118
Originally Posted by rolan900d View Post
Buddy. where you have updated it?

On page 4 it is stated that the last update was done yesterday
the attachment of page 4 is updated now.
but i posted the code above.
so you could just make a new file and copy & paste it. *G*

edit:
sorry... but i have to say it... /dev/urandom is a b*tch !!! ^^

Last edited by b666m; 2010-02-21 at 16:57.
 

The Following User Says Thank You to b666m For This Useful Post:
Posts: 527 | Thanked: 121 times | Joined on Feb 2010
#119
Got it!

Cheers
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#120
wow... that was really tricky... but like hatebreed would shout it:

a lesson lived is a lesson learned
 
Reply


 
Forum Jump


All times are GMT. The time now is 07:09.