Thelete na sas hackepsw sta grhgora?
Dimitrios Apostolou
jimis at gmx.net
Wed Oct 18 01:12:43 EEST 2006
Giorgos Keramidas wrote:
> To `hack' eksartatai apo polla pragmata:
>
> a) Apo thn yparksh tou LESSOPEN sto environment tou root
>
> b) Apo to gegonos oti to /bin/sh se Linux einai to bash
>
> c) Apo to gegonos oti kaneis 'echo' pragmata pou den prepei apo to
> .bashrc file
>
> Nai, ontws to `lesspipe.sh' malakizetai opws tha deis parakatw:
>
> fedora# env | grep LESS
> LESSOPEN=|/usr/bin/lesspipe.sh %s
> fedora# tail -1 .bashrc
> echo Hello world
> fedora# less /etc/passwd | col -b | head -3
> Hello world
> fedora#
>
> *AKRIBWS* se ayto anaferomoun sta prohgoumena posts. H lysh einai poly
> aplh. Den bazoume sto environment tou root blakeies:
>
> fedora# unset LESSOPEN
> fedora# less /etc/passwd | col -b | head -3
> root:x:0:0:root:/root:/bin/bash
> bin:x:1:1:bin:/bin:/sbin/nologin
> daemon:x:2:2:daemon:/sbin:/sbin/nologin
> fedora#
>
> Autou tou eidous to `bug' omws yparxei mono se Linux (pou exei to bash
> ws /bin/sh by default), mono an eisai root, kai mono an exeis dialysei
> to .bashrc sou (mono, dhladh, an to LESSOPEN einai set sto environment).
>
> Apla twra ksereis giati kata kairous stelnw email me brisidia otan blepw
> kaloproairetes alla xazes allages se system-wide startup scripts, opws
> to parakatw (tyxaio paradeigma apo fetos):
Se scientific linux, ke fantazome se kathe redhat-like dianomi (fedora,
centos):
# less /etc/passwd|cat
Hello world
Ap'oti fenete to bug den ine linux-specific, oute bash-specific. Ine
malon lesspipe.sh-specific, giati alios tha sinevene to idio me kathe
bashoscripto. :-) Sigkekrimena, to .bashrc pou mas kani ti zimia, den
ektelite katefthian apo to bash, ala apo to .bash_profile pou ehi tis
akolouthes grammes:
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
Opote den boroume na katigorisoume to bashaki afou to .bashrc to ekteli
mono otan prokite gia interactive shell:
> When an interactive shell that is not a login shell is started, bash
> reads and executes commands from ~/.bashrc,
To .bash_profile ektelite lipon kathos to lesspipe.sh kalite lanthasmena
me login shell:
$ head -1 /usr/bin/lesspipe.sh
#!/bin/sh -
Ke afto ine i pigi olon ton provlimaton mas! Vgazontas tin pavla ola tha
eprepe na pezoun komple.
Etsi nomiza otan arhisa na grafo to minima...
Anakalo pliros omos. Afto pou argisa na katalavo ine giati sta
redhat-like sistimata pou doulevi afto, doulevi mono san root (login san
root) ke ohi san user! I apantisi telika ine oti to /root/.bash_profile
periehi tin akolouthi moufa, i opia ke den iparhi alou:
BASH_ENV=$HOME/.bashrc
Etsi simfona me to man bash:
> When bash is started non-interactively, to run a shell script, for
> example, it looks for the variable BASH_ENV in the environment, expands
> its value if it appears there, and uses the expanded value as the name
> of a file to read and execute.
Ara telika, afou den prokite gia interactive shell, kata kanona den
ektelite oute to .bashrc oute to .bash_profile (i pavla lipon /malon/
den pezi kanena rolo). Apla epidi sto environment tou root ine
settarismeni i BASH_ENV=.bashrc, gi'afto to logo kalite to .bashrc.
An commentaroume lipon tin parapano grammi ke ksanakanoume login, to
less tha doulevi kanonika. Isos sikoni ke bug-report?
Dimitris
P.S. To enigma pou parameni ine giati to Hello world ine *to mono* pou
emfanizete, ke ohi apla san proti grammi se o,ti kanoume less.
P.P.S. Foti, emena pantos me hackepses kathos mesa se oles tis moufes
pou ekana, egrapsa se mia fasi 'less .bashrc' ke ehasa ti bala me afto
pou (den) ida... Epsahna na do ti esvisa ke pote, i pou evala katalathos
> anti gia >>
More information about the Linux-greek-users
mailing list