Labels

freebsd (12) AWS (9) linux (8) mysql (8) EC2 (7) auto-scaling (7) php (7) unix (7) howto (5) amazon (4) example (4) php5.3 (4) /usr/ports (3) backup (3) bash (3) cloud (3) cloudwatch (3) ffmpeg (3) loadbalancer (3) mycld (3) patch (3) php53 (3) scaling (3) scalr (3) security (3) spot instances (3) sql (3) tutorial (3) AWSSDKforPHP (2) CentOS (2) WSDL (2) ZEND framework (2) alarms (2) bug (2) cache (2) cloudfusion (2) console (2) exploit (2) fileinfo (2) fix (2) lauchconfig (2) mysqldump (2) mysqlse (2) php-fpm (2) policies (2) ports (2) portupgrade (2) redhat (2) sed (2) shell (2) sphinx (2) sphinxse (2) video (2) x264 (2) /etc/motd (1) 9.x (1) ELB (1) MP4Box (1) MySQL status codes HY000 sqlstate sql states (1) OS (1) RFC (1) SIP (1) URI (1) alias (1) apache (1) banner (1) big databases (1) blog (1) bsd (1) bugtraq (1) checklist (1) chkconfig (1) clean (1) cleaning (1) clear (1) code (1) conf (1) configs (1) configuration (1) content type (1) converting (1) core (1) cron (1) cve (1) database (1) debian (1) deinterlasing (1) dependency (1) disable (1) dump (1) editor (1) editors (1) email (1) encoding char utf8 latin1 script linux bash (1) error (1) escaping (1) exim (1) expat (1) exploits (1) extensions (1) faac (1) fastcgi (1) feed (1) figlet (1) fps (1) freebsd-update (1) freeswitch (1) fresh installation (1) gcc (1) geo (1) gop (1) gpac (1) grep (1) h.264 (1) h264 (1) hitrate (1) hostname (1) incremental (1) init (1) init.d (1) innobackupex (1) ivp6 (1) keyint_min (1) libx264 (1) libxml2 (1) list (1) mail (1) make (1) map (1) maxmind (1) mencoder (1) mime (1) mindmeister (1) mindmeister.com (1) mp4 (1) mplayer (1) mta queue (1) mysql charset (1) mysql charset encoding char utf8 latin1 script linux bash (1) networking (1) nginx (1) nmap (1) optimization (1) paranoia (1) paranoiac (1) percona (1) performance (1) portdowngrade (1) portsnap (1) postgre (1) postgres (1) postgresql (1) presets (1) putty (1) query cache (1) rc (1) rc.conf (1) rc.d (1) remote (1) restore (1) rhel (1) rhel5 (1) script (1) scrubing (1) seclist (1) seclist.org (1) seek (1) seeking (1) segfault (1) slow loris (1) slowloris (1) smtp (1) software (1) sphinxsearch (1) stty (1) terminal (1) time (1) timezone (1) tmp (1) transcoding (1) tty (1) update (1) video transcoding (1) vulnerabilities (1) wal-e (1) web (1) web servers (1) wordpress (1) x86_64 (1) xtrabackup (1) yum (1) zend (1)

Sunday, 20 September 2015

Bash pitfails

Usefull article:
Common errors that Bash programmers make.

-- vladget

Simple bash script for sorting tons of photos and videos

 
Work on Mac OS X only.

#!/bin/bash


prefix="Timka.iPAD"
srcdir="/Users/vladget/Pictures/Медиатека Фото.photoslibrary/Masters/2015/09/19/20150919-144326"
dstdir="/Users/vladget/photos"
mkdir -p "$dstdir"

# do not use ls!
# http://mywiki.wooledge.org/ParsingLs
for file in $srcdir/*; do
  dstsubdir="$dstdir"/$(date -r `stat  -f "%m" "$file"` "+%Y.%m.%d."$prefix".")
  if [ ! -d "$dstsubdir" ]; then
    mkdir -p  "$dstsubdir"
  fi

  mv "$file" "$dstsubdir"/
done

Friday, 1 May 2015

Fix dependency hell with expat-2.1.0-8.18.amzn1.x86_64 on amazon linux

# yum update
...
Resolving Dependencies
...
Error: Package: python24-libs-2.4.6-56.31.amzn1.x86_64 (@amzn-main)
           Requires: libexpat.so.1(EXPAT_2_0_1_RH)(64bit)
           Removing: expat-2.0.1-11.9.amzn1.x86_64 (@amzn-updates)
               libexpat.so.1(EXPAT_2_0_1_RH)(64bit)
           Updated By: expat-2.1.0-8.18.amzn1.x86_64 (amzn-main)
               Not found
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest


# yum erase python24-libs-2.4.6-56.31.amzn1.x86_64
...
Dependency Removed:
  denyhosts.noarch 0:2.6-24.el5.art                                                                                    python24.x86_64 0:2.4.6-56.31.amzn1                                                                                  

Complete!

# yum update

...
Complete!
-- vladget

Saturday, 11 April 2015

Freeswitch 1.4.18 and URL encoding in SIP

Last released Freeswitch version 1.4.18 was implement URI escaping at SIP messages.
Here is some excerpt from RFC regarding this:

The MAIN SIP RFC 3261:
http://tools.ietf.org/html/rfc3261
...
...
SIP-URI          =  "sip:" [ userinfo ] hostport
                    uri-parameters [ headers ]
SIPS-URI         =  "sips:" [ userinfo ] hostport
                    uri-parameters [ headers ]
userinfo         =  ( user / telephone-subscriber ) [ ":" password ] "@"
user             =  1*( unreserved / escaped / user-unreserved )


   The BNF for telephone-subscriber can be found in RFC 2806 [9].  Note,
   however, that any characters allowed there that are not allowed in
   the user part of the SIP URI MUST be escaped.
...
...

   SIP follows the requirements and guidelines of RFC 2396 [5] when
   defining the set of characters that must be escaped in a SIP URI, and
   uses its ""%" HEX HEX" mechanism for escaping.  From RFC 2396 [5]:

      The set of characters actually reserved within any given URI
      component is defined by that component.  In general, a character
      is reserved if the semantics of the URI changes if the character
      is replaced with its escaped US-ASCII encoding [5].  Excluded US-
      ASCII characters (RFC 2396 [5]), such as space and control
      characters and characters used as URI delimiters, also MUST be
      escaped.  URIs MUST NOT contain unescaped space and control
      characters.


Check the RFC 2396
http://tools.ietf.org/html/rfc2396

2.3. Unreserved Characters


   Data characters that are allowed in a URI but do not have a reserved
   purpose are called unreserved.  These include upper and lower case
   letters, decimal digits, and a limited set of punctuation marks and
   symbols.

      unreserved  = alphanum | mark

      mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"

   Unreserved characters can be escaped without changing the semantics
   of the URI, but this should not be done unless the URI is being used
   in a context that does not allow the unescaped character to appear.

2.4. Escape Sequences


   Data must be escaped if it does not have a representation using an
   unreserved character; this includes data that does not correspond to
   a printable character of the US-ASCII coded character set, or that
   corresponds to any US-ASCII character that is disallowed, as
   explained below.

...

2.4.3. Excluded US-ASCII Characters

   Although they are disallowed within the URI syntax, we include here a
   description of those US-ASCII characters that have been excluded and
   the reasons for their exclusion.

   ...

   The angle-bracket "<" and ">" and double-quote (") characters are
   excluded because they are often used as the delimiters around URI in
   text documents and protocol fields.  The character "#" is excluded
   because it is used to delimit a URI from a fragment identifier in URI
   references (Section 4). The percent character "%" is excluded because
   it is used for the encoding of escaped characters.

   delims      = "<" | ">" | "#" | "%" | <">

   Other characters are excluded because gateways and other transport
   agents are known to sometimes modify such characters, or they are
   used as delimiters.


and RFC 3986 which describe general syntax of URI
https://tools.ietf.org/html/rfc3986
2.2. Reserved Characters


   URIs include components and subcomponents that are delimited by
   characters in the "reserved" set.  These characters are called
   "reserved" because they may (or may not) be defined as delimiters by
   the generic syntax, by each scheme-specific syntax, or by the
   implementation-specific syntax of a URI's dereferencing algorithm.
   If data for a URI component would conflict with a reserved
   character's purpose as a delimiter, then the conflicting data must be
   percent-encoded before the URI is formed.

      reserved    = gen-delims / sub-delims

      gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"

      sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
                  / "*" / "+" / "," / ";" / "="

   The purpose of reserved characters is to provide a set of delimiting
   characters that are distinguishable from other data within a URI.
   URIs that differ in the replacement of a reserved character with its
   corresponding percent-encoded octet are not equivalent.  Percent-
   encoding a reserved character, or decoding a percent-encoded octet
   that corresponds to a reserved character, will change how the URI is
   interpreted by most applications.  Thus, characters in the reserved
   set are protected from normalization and are therefore safe to be
   used by scheme-specific and producer-specific algorithms for
   delimiting data subcomponents within a URI.

 
-- vladget