The Sibyl is a project invented and implemented by Pedro (pfortuny) and me (rafacas). Although I have to admit that it was Pedro’s idea.
It started with the goal of secure storage of the shadow file and, in general, of any database of secret authentication tokens (think of passwords -actually hashes of passwords- of users of a Web-based service, for example). We consider it addresses the main concern on those databases: dictionary attacks and rainbow tables, which have become available at negligible cost: there is a cloud-based service for doing dictionary attacks on a WPA key.
Our approach for storing shadow files is to use a separate server for checking the correctness of the password introduced by the user, taking advantage of asymmetric key encryption.
Instead of keeping the hash (as crypt(3) does, or SHA1) of the password in the shadow file, we store an OAEP RSA-cyphertext of the hashed password (using a public encryption key) and, each time the user tries to log in, ask via TCP someone (the owner of the private key) if another OAEP-encryption of the hash of the password issued by the logging user matches the stored token. That is: use an”oracle” to check if the user has entered the correct password or not. This “oracle”, which is a standalone machine, is the Sibyl and the device we use to implement it is a Bifferboard.
The details are on the web of the Sibyl project. We hope you like it and use it.
Welcome to a new issue of this short Vim tutorial!
As we saw in previous posts, Vim is the perfect tool if you want to save time in your daily work. It helps you in the write-compile-debug cycle, it indents and autoindents code, it is extremely powerful for searching, replacing and many other frequent tasks.
In this post I will introduce an interesting feature meant to make you type less: abbreviations.
Abbreviations are, as their name indicates, a way to create an association between a short set of characters and a piece of text (or a command).
Abbreviations can be used in insert, replace or command mode. The keywords used to work with abbreviations are all the same, but adding a proper prefix if necessary (i for insert mode, c for command mode and ! for both).
iab Create abbreviation for theinsert mode
cab Create abbreviation for the command mode
Recently, I had to write a dockbook template using perl and the Mason library and found myself typing continuously the following thing:
$data->[0]->{}
and between the curly braces the hash key. After writing that twice I got bored of doing it (yep, I am a lazy guy) so I created the following abbreviation:
iab dh $data->[0]->{!cursor!}:call search('!cursor!', 'b')cf!
It associates the “dh” characters with the $data->[0]->{!cursor!}:call search(‘!cursor!’, ‘b’)cf! string. This string writes “$data->[0]->{}” and places the cursor between the curly braces (do not worry about the “call search” stuff, the example could have been iab dh $data->[0]->{} ) By the way, abbreviations are not recursive, so you will never end up stuck in an infinite loop.
Since writing a tag-like document is a real pain, I decided to abbreviate some of the common tags I was using the most, so I created the following abbreviations:
iab fp <formalpara><CR><LF></formalpara>
iab p <para></para>
iab il <itemizedlist><CR><LF></itemizedlist>
iab li <listitem></listitem>
iab e <entry><CR><LF></entry>
iab t <title></title>
iab it <informaltable><CR><LF></informaltable>
iab r <row><CR><LF></row>
<CR> and <LF> have the common meanings (Carriage Return and Line Feed respectively). They were very convenient. You can copy them to your .vimrc file.
But what if you do not want an abbreviation to be expanded?
Suppose we have the following abbreviation:
iab to Total
and we want to write the following sentence:
"I went to Paris"
As soon as you type the space after “to”, the abbreviation will be expanded and you will end up with:
"I went Total "
To avoid this problem, press Ctrl-V after the problematic abbreviation and then continue typing normally.
To disable an abbreviation permanently you can use “unabbreviate”. For instance:
:unabbreviate dh
“abbreviate” lists the current abbreviations. E.g:
i t Total
i b back
The first column shows the mode in which the abbreviate is available, the second shows the abbreviation and the third one the text it expands to.
Abbreviations are a convenient way of saving some (or possibly a lot of) work, specially if it is repetitive.
Vim Sheet(VII)
- [i/c/!]ab Create an abbreviation in the specified mode
- unabbreviate Deletes an abbreviation
- abbreviate List available abbreviations
On FreeBSD, we use the
pkg_info command this way:
$pkg_info -W /usr/local/bin/mysql
/usr/local/bin/mysql was installed by package mysql-client-5.5.2
Enjoy!
I cannot help copying this snippet. Assume f is a (char *) of length L, containing an hex string like '0aabdda' (without the leading “0x”, like something coming from a sha function —or like the sha1 stored by Leopard in the password files, which is the origin of this problem). You want to transform it into the corresponding sequence of bytes (that is, assuming the string is of even length, otherwise, we add a trailing, yes, trailing, at the end, ’0′). We shall store the result in t, which points to a (char *) of length L/2.
The following C code does the trick: (first of all we must set t to 0);
int k = (L%2 ? L/2+1 : L/2);
memset(t, 0, L/2);
for(i=0; i<L; i++){
t[i/2] += ((i%2) ? 1 : 16) *
((f[i] > 'F') ? (f[i] - 'a' + 10) :
((f[i] > '9') ? (f[i] - 'A' + 10) :
(f[i] - '0')))
}
Thus, if f points to the string 100aff, t points to the sequence of bytes 16, 10, 255 after the loop.
The reverse operation is well known:
for(i=0; i<k; i++){
sprintf(f+2*i, "%02X", t[i]);
}
I just don’t want to forget it.
It took me quite a while to realize that the following line does not do what you think it does:
$ echo '$1$CSmo96nX$G0PL/Cs/of5qDN2vMnyHp0' | openssl base64 | tr -d '\n'
You should always use the -n option if you want to make sure there is no spurious trailing newline:
$ echo -n '$1$CSmo96nX$G0PL/Cs/of5qDN2vMnyHp0' | openssl base64 | tr -d '\n'
(By the way, the encrypted message says just 'patata0' and it is not my password).
Or… is it?
Tested on two Linux systems (Fedora & Ubuntu) and one Snow Leopard.
When editing LaTeX files, I usually call the master file of a project 00father.ltx for historical reasons. Moreover, the following line is part of my .emacs:
(setq-default TeX-master "00father.ltx")
because most of the time I am editing multifile projects.
However, from time to time I need to write a single-file document and in this case, naming it 00father.ltx is not that useful, and I do not want to have to set the master-file variable each time I load the file.
There is an easy way to get this done. Just include a line at the top of the file -as a comment in the appropriate language- setting the variables. The syntax is as follows (in C, for example):
/* -*- variable1: value1; variable2: value2; -*- */
I am giving two examples. The first one in C again. Assume this is the header of a file called trial.c
/* *-* tab-width: 8; column-number-mode: 1; fill-column: 80; -*- */
The line tells emacs to set the length of a tab to 8 spaces (usual in BSD), to show the column number in the information line and to wrap lines (if wrapping -fill-mode- is set) at 80 characters.
For my LaTeX issue, the first line of a single-file document letter_to_my_friend.ltx goes as follows (notice the difference in the comment syntax):
% -*- TeX-master: "letter_to_my_friend.ltx"; -*-
I have checked and if your file is a shell script, which usually begins with
#!/bin/sh
(or some similar line), you can place the variable-setting line just afterwards.
To rollback (that is, revert to a previous version) some files/dirs… using subversion, you need as Aral Balkan explains to
- Merge the previous version
- Commit
Like this (assumming you want to roll back from version 61 to 58):
pera $ svn merge r61:58 https://my.project.at.sourceforge/svnroot/project/dir1/src/
[... output ...]
pera $ svn ci -m "Reverted to version 58"
which is strange but works. Forget about the revert command, it has a different functionality.
You may want to run
pera $ svn merge --dry-run r61:58 ........
to check the changes which will take place before messing everything up.
ipcs shows the status of SYSV inter process communication facilities.
$ ipcs -s
------ Semaphore Arrays --------
key semid owner perms nsems
0xdd3adabd 0 fernape 600 1
I had forgotten about this command but I remembered it when we ran out of semaphores in our Linux system two days ago.
Other way of getting the same information is to cat the following files:
$ ls /proc/sysvipc
msg sem shm
Enjoy!
Sometimes I need a timer to focus on something and to alert me when to stop. Remember, we are real commandliners, so we do not want those fancy applications with a lot of features, we need a script ;-) so here it is:
#!/bin/bash
usage() {
name=`basename $0`
echo "Usage: $name hh:mm:ss"
echo "Example: $name \"00:15:30\""
}
if [ $# != 1 ]
then
usage
exit
fi
IFS=:
set -- $*
secs=$(( ${1#0} * 3600 + ${2#0} * 60 + ${3#0} ))
while [ $secs -gt 0 ]
do
sleep 1 &
printf "\r%02d:%02d:%02d" $((secs/3600)) $(((secs/60)%60)) $((secs%60))
secs=$(( $secs - 1 ))
wait
done
echo
It works in any POSIX shell.
I was writing one but I found this thread of the UNIX and linux forum where the user cfajohnson solves it in a better way.
The code:
sleep 1 &
...
wait
minimizes the skew of the loop, so every cycle is as close to 1 second as possible.
I have not included the final beep in the script. You can do it with the usual:
printf ("\a")
which works on all unix-like systems.
In linux you can use the beep command that allows you to control pitch, duration, and repetitions, for example:
$ beep -f 300.7 -r 2 -d 100 -l 400
makes 2 repetitions of a beep at 300.7 Hz for 400 milliseconds and a delay between repetitions of 100 milliseconds.
In OS X you can play with the say command:
$ say "You deserve some rest"
Tagged:
basename,
beep,
countdown,
exit,
if,
IFS,
POSIX,
printf,
say,
set,
sleep,
wait,
while
Sometimes I need to download a file from a computer with multiple net interfaces, but only one is connected to the Internet. In these cases I use the bind-address option of the wget command, which binds the connection to the address specified in the local machine.
$ wget --bind-address=192.168.213.141 \
> ftp://ftp.icm.edu.pl/vol/rzm1/linux-fedora-secondary/development/source/SRPMS/ppp-2.4.4-11.fc11.src.rpm
--2010-03-27 12:25:56-- ftp://ftp.icm.edu.pl/vol/rzm1/linux-fedora-secondary/development/source/SRPM/ppp-2.4.4-11.fc11.src.rpm
=> `ppp-2.4.4-11.fc11.src.rpm.1'
Resolving ftp.icm.edu.pl... 193.219.28.140
Connecting to ftp.icm.edu.pl|193.219.28.140|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /vol/rzm1/linux-fedora-secondary/development/source/SRPMS ... done.
==> SIZE ppp-2.4.4-11.fc11.src.rpm ... 724348
==> PASV ... done. ==> RETR ppp-2.4.4-11.fc11.src.rpm ... done.
Length: 724348 (707K)
100%[========================================>] 724,348 173K/s in 4.1s
2010-03-27 12:26:03 (173 KB/s) - `ppp-2.4.4-11.fc11.src.rpm.1' saved [724348]