Monday, 1 July 2019

unix - Bash: Spaces in alias name


I am trying to create an aliases in bash. What I want to do is map ls -la to ls -la | more


In my .bashrc file this is what I attempted:


alias 'ls -la'='ls -la | more'


However it does not work because (I assume) it has spaces in the alias name. Is there a work around for this?



Answer



The Bash documentation states "For almost every purpose, shell functions are preferred over aliases." Here is a shell function that replaces ls and causes output to be piped to more if the argument consists of (only) -la.


ls() {
if [[ $@ == "-la" ]]; then
command ls -la | more
else
command ls "$@"
fi
}

As a one-liner:


ls() { if [[ $@ == "-la" ]]; then command ls -la | more; else command ls "$@"; fi; }

Automatically pipe output:


ls -la

port forwarding - VirtualBox webserver not accessbile on host browser


I setup and installed a CentOS6 webserver on a virtualbox.


Already setup port-forwarding of port 4444 to 80 so that I can access it and even disabled Win7 firewall.


I think that probably the problem is in apache httpd so I install lynx and I can view the test.html I created. But I can't access it in the host browser.


ifconfig says the guest ip is 10.0.2.15 so when I try to access it in my web browser on i type : http://10.0.2.15:4444


I don't know what's wrong with my setup


EDIT: 127.0.0.1:4444 doesn't work either


EDIT: Switched network type to bridged networking, still has windows firewall disabled, removed port-forwarding setting on virtualbox and I still could not access the web server. :(



Answer



Finally found the cause. Apparently, CentOS 6 iptables block httpd port 80 outside by default.


How to clear Windows File Cache?

For testing purposed I need to clear file cache (for example to measure file operation performance).


I found CacheSet from sysinternals, but pressing Clear there doesn't help. A file that I just copied to Nil when copied again do this in a blink of an eye (while the initial operation took significant 2 seconds).


Does it mean that HD has its own caching that can't be canceled or cleared?

networking - Configuring old router as repeater?


I have been at it for about two days and let me give a detailed account of all the settings that I have set.


For the sake of clarity I will call the router which as Internet connection (WAN) as the mainRouter and the old router which I want to use as a repeater as the the secondRouter.


In the screenshots I have the SSID of the mainRouter as iball100 and that of the secondRouter as iballRep


Here are the settings for the mainRouter


Main router settings


And now for the Settings for the secondRouer


enter image description here


The problem that i have is that the secondRouter does not have access to the internet. When I connect to the secondRouter it says "connected,No internet". I have tried connecting to it using my phone as well still get the same thing.


The secondRouter doesn't show as a connected client on the mainRouter, is a thing that I observed.


I have no clue as to what am I missing here. The settings that I have work well for youtube videos which I saw, link here.


Any help in this regard will be appreciated.



Answer



According to the manual for the second device: iB-WRX150NE, it does not have a repeater mode. It can act in Wireless Router mode or Wireless Client Router mode. The Wireless Client Router mode allows you to connect wired clients using this router as a bridge to the other wireless network. It cannot wirelessly provide access and also act as a bridge.


See section 4.5 Operation mode:


https://www.iball.co.in/File/Product/Drivers/iB-WRX150NE%20User%20Manual.pdf


linux - Passing PATH through sudo


In short: how to make sudo not to flush PATH everytime?


I have some websites deployed on my server (Debian testing) written with Ruby on Rails. I use Mongrel+Nginx to host them, but there is one problem that comes when I need to restart Mongrel (e.g. after making some changes).


All sites are checked in VCS (git, but it is not important) and have owner and group set to my user, whereas Mongrel runs under the, huh, mongrel user that is severely restricted in it's rights. So Mongrel must be started under root (it can automatically change UID) or mongrel.


To manage mongrel I use mongrel_cluster gem because it allows starting or stopping any amount of Mongrel servers with just one command. But it needs the directory /var/lib/gems/1.8/bin to be in PATH: this is not enough to start it with absolute path.


Modifying PATH in root .bashrc changed nothing, tweaking sudo's env_reset and env_keep didn't either.


So the question: how to add a directory to PATH or keep user's PATH in sudo?


Update: some examples


$ env | grep PATH
PATH=/usr/local/bin:/usr/bin:/bin:/usr/games:/var/lib/gems/1.8/bin
$ sudo cat /etc/sudoers | egrep -v '^$|^#'
Defaults env_keep = "PATH"
root ALL=(ALL) ALL
%sudo ALL=NOPASSWD: ALL
$ sudo env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin

Also I can say that it works exactly this way in Debian stable (lenny) too.



Answer



Struggled with the same problem for a few hours. In debian lenny, you can fix it by adding


Defaults        exempt_group= 

to the sudoers file.


This is the only way to go around the compiled --secure-path option, (as far as I know).


Notably, this will also exempt users from needing to enter their password when they sudo.


security - Thunderbird: Error: imap.server.com : server does not support RFC 5746, see CVE-2009-3555


I'm getting this error when checking my mail, and I can't download my mail. I recently updated Thundirbird yesterday, but it restarted and was working fine for many hours. I saw this question: How to add an account when Thunderbird warns "potentially vulnerable to CVE-2009-3555"?, which led to https://wiki.mozilla.org/Security:Renegotiation, and I checked my config editor, and the following are still at their default values:


security.ssl.require_safe_negotiation;false
security.ssl.treat_unsafe_negotiation_as_broken;false
security.ssl.warn_missing_rfc5746;1

I found the original references to these errors, but they are from 2010. It's hard to believe the server was not updated since then. http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-3555, http://tools.ietf.org/html/rfc5746


I tried to open a connection from the command line, and it worked fine:


$ openssl s_client -connect imap.spamarrest.com:993
CONNECTED(00000003)
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify error:num=20:unable to get local issuer certificate
---
Certificate chain
0 s:/C=US/ST=Washington/L=Mercer Island/O=Spam Arrest LLC/CN=*.spamarrest.com
i:/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G2
1 s:/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G2
i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIEyTCCA7GgAwIBAgIQGYgqh31QZsgNdrzNLIRl0zANBgkqhkiG9w0BAQUFADBE
MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMU
R2VvVHJ1c3QgU1NMIENBIC0gRzIwHhcNMTMwNzI1MDAwMDAwWhcNMTUwNzI1MjM1
OTU5WjBvMQswCQYDVQQGEwJVUzETMBEGA1UECBQKV2FzaGluZ3RvbjEWMBQGA1UE
BxQNTWVyY2VyIElzbGFuZDEYMBYGA1UEChQPU3BhbSBBcnJlc3QgTExDMRkwFwYD
VQQDFBAqLnNwYW1hcnJlc3QuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOC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CTK4QymkX7KloX5+c6mQUIPnw8OlHHX/1wgPuHW61reytRaFpC0mF/7l
rdOMEp7bf8XgqihidJx0PN6QBkYJ93jcGLC/Z+RB/YbfZ5PlssLmAttSdBe8ICKp
5JZasTIJsKLmOEePx22wgSCSs90WBCtWwFWMgySL0is06kyyO8f41pxecn1l+ZUL
akBDXv0v2MEZ1Bt/zMdfb+HIZ2qrDbu7DkLPaxg=
-----END CERTIFICATE-----
subject=/C=US/ST=Washington/L=Mercer Island/O=Spam Arrest LLC/CN=*.spamarrest.com
issuer=/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G2
---
No client certificate CA names sent
---
SSL handshake has read 3560 bytes and written 672 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: zlib compression
Expansion: zlib compression
No ALPN negotiated
SSL-Session:
Protocol : TLSv1
Cipher : AES256-SHA
Session-ID: E9038FFAE57B8F588299E197E5B5698AD51E595B6E2BFEEBA0ABA899ABDC1FCF
Session-ID-ctx:
Master-Key: 3CAD63BB946E9F696BD5259472E16A4C4616B41020A30C67A5CDDBC9BE063C702A0F0A7BE83AF98EB61D1F27A8B89E67
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket:
0000 - e6 4e d4 d0 12 78 e6 ad-ce a5 b0 84 4d 59 ea 1d .N...x......MY..
0010 - fc a2 61 c2 36 e8 d5 a6-f2 3f da 74 b6 7a d7 c1 ..a.6....?.t.z..
0020 - eb ac cf da 9a 21 02 70-da 85 38 d6 28 83 31 fe .....!.p..8.(.1.
0030 - e1 8d 14 ee 55 c7 02 5d-97 a3 3e cb d7 b8 70 de ....U..]..>...p.
0040 - 76 95 02 02 7c d8 5a 1a-f7 60 d8 fa ad f6 9f fb v...|.Z..`......
0050 - e1 30 92 ef 09 58 08 73-22 2c 1c bc 3c f0 a1 a5 .0...X.s",..<...
0060 - a9 bd fb 09 52 a4 9d cd-6b a6 9c 5e 42 ab 7c b3 ....R...k..^B.|.
0070 - 45 46 17 00 59 0a 3f b6-20 41 40 a3 2e 88 39 2c EF..Y.?. A@...9,
0080 - 4e 7d e6 09 ed 02 8f 3c-1e 9c 9c ce d9 88 cf 73 N}.....<.......s
0090 - 0e d6 87 83 4a 86 30 13-22 16 9c 13 b8 17 fd ba ....J.0.".......

Compression: 1 (zlib compression)
Start Time: 1434915194
Timeout : 300 (sec)
Verify return code: 20 (unable to get local issuer certificate)
---
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=CRAM-MD5 AUTH=PLAIN ACL ACL2=UNION] IMAP ready.
closed

So how do I work around this problem to fetch my mail? I've already notified the support of the server, but have not heard back.


Thunderbird 38.0.1
OpenSSL 1.0.2a 19 Mar 2015




It's happened for two consecutive updates. Is this a fault with Thunderbird or the mail server?



Timestamp: 8/19/2015 3:54:37 PM Error: uncaught exception: 2147746065


Timestamp: 8/19/2015 3:54:37 PM Error: mail.spamarrest.com : server does not support RFC 5746, see CVE-2009-3555




Answer



RFC 5746 describes a Transport Layer Security (TLS) Renegotiation Indication Extension, which is intended to protect against attackers injecting data into the connection early on and thus tricking clients and servers into communicating with each other in a manner that is vulnerable to a man in the middle attack.


CVE-2009-3555 is an old (late 2009) Common Vulnerability and Exposures identifier that basically allows you to learn more about products and product versions which are vulnerable or not to this specific attack. It's similar to a bug report ID or issue number that a vendor might assign to a problem report, except CVEs can (and in this case it certainly does) cover many different applications.


Thunderbird is informing you (though I agree, definitely not in a very user-friendly manner) that the server you are connecting to does not support the standard that was developed to mitigate this threat, and is aborting the connection attempt because this presents a potential security vulnerability leading to loss of privacy (specifically data confidentiality, in this case of both authentication credentials as well as email traffic).


The place where this needs to be fixed is on the mail server you are connecting to, so you should urge your service provider to immediately upgrade to software that mitigates CVE-2009-3555. Alternatively, since the problem has been known for six years and the fix has been standardized for five and a half years, I would have doubts about what other potential security issues the service provider is not taking seriously, and personally would probably look for alternative service providers.


If you don't care about privacy, then you can try to mitigate this by turning off TLS/SSL in your Thunderbird account settings, thus using plain-text mail transmission between your Thunderbird client and the mail server. This however leaves you potentially vulnerable to various threats, including pervasive monitoring. Additionally, this mitigative strategy requires that your service provider's mail server allows plaintext sessions in the first place; it's becoming more and more common for service providers to configure their systems such that only encrypted connections are allowed, particularly for authenticated workflows. Hence, this mitigative strategy may or may not be available in your specific case, and even if it is, is not a recommended approach.


Note that ignoring this problem (by switching to plain-text email transfer) affects not just you, but also potentially everyone that you correspond with over email. Even if you (contrary to best current Internet engineering practice) feel that pervasive monitoring is not a threat in your situation, those you correspond with might feel differently.


virtualbox - extending xorg.conf to account for a boot from virtual box


i have a ubuntu10.10/win7 dual boot. i use win7 as a host for virtual box and run the existing ubuntu in virtual box.


when i installed vb additions and extensions, the xorg.conf file got overwritten.


depending on how i would boot (natively or through virtual machine) i have to change xorg.conf file manually. is there a way to make it automatic? putting both configs into xorg.conf file didn't work.


i filed a ticket couple days ago http://www.virtualbox.org/ticket/8360 but got no response. i'm sure there is a quick fix for this. any ideas??? i documented my experience (if u need more details) here: http://kirilligum.wordpress.com/2011/02/17/run-existing-linux-ubuntu-10-10-partition-in-virtualbox-under-host-windows-7-system-on-thinkpad-x201t/



Answer



Create a script in /etc/init.d that runs during boot that detects whether or not it's running in a VirtualBox VM, and install the appropriate xorg.conf. Something similar to this should work:


if [ `dmidecode -s system-product-name` = "VirtualBox" ]
then
cp /etc/X11/xorg.conf.vbox /etc/X11/xorg.conf
else
cp /etc/X11/xorg.conf.real /etc/X11/xorg.conf
fi

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...