Solrex's profileSolrex Shuffling.LifeBlogListsNetwork Tools Help

Blog


    10/30/2007

    Differential Cryptanalytic Attack of 3-Round DES


    我发现自己做事情老是有虎头蛇尾的习惯,就像文章标题的这篇实验报告一样,本来我的题目是 Differential Cryptanalytic Attacks of Reduced Round DES,后来发现写对更多轮的 DES 攻击代码太困难。其实密码分析很简单,都是别人做过的东西,拿来抄抄就是了,但是实际写起来代码才发现完全不是那么回事。文章中一句话带过的东西可能需要你编码好长时间再加调试,而且还很难找到正确代码做比较,所以写到后来实在泄气,就只写好了一个3轮的攻击,再加上我时间本来就不多,只好作罢。等以后有闲功夫了我再恢复原来那标题吧 :)

    鉴于自己在做作业时找代码样例对比的难处,像上次的大作业一样,我把我对 3 轮 DES 差分攻击的实验报告又放到了我的个人网站共享空间里,可以从 http://share.solrex.cn/MyWork/dc_des_lr.pdf 下载。这篇文章主要内容是对 3 轮 DES 差分攻击特征的分析和实现,文章里面有全部 DES 加密解密和 3 轮攻击的源代码。本来我觉得我的实验报告够挫的了,因为都是别人已经做出来的东西。后来我发现在 2003 年 8 月份的《计算机工程》杂志上登过这样一篇文章《数据加密标准DES分析及其攻击研究》,基本信息量为0,连引用文献都没有写到 Eli Biham 和 Adi Shamir 经典文章,我庆幸我好歹还附上了代码...希望能对某些对密码学有点兴趣的人有所帮助。

    顺便说几句废话,看到 Eric师兄在博客里说 PageRank,我查看了一下我 Wordpress 博客 http://blog.solrex.cn 的 PageRank,嘿嘿,居然有到 2 ?我怀疑自己是不是看花了眼,在 Win 下的 Firefox Google 工具栏,IE Google 工具栏,Linux 下的 Firefox Google 工具栏查看了三遍,都是显示 2(希望 Google Toolbar 没有耍我)。哈哈,我的博客网站居然也有 PageRank 了!大家以后多到 http://blog.solrex.cn 踩我吧,另外链接我博客时候最好也用这个链接,别用 Space 或者 Blogspot 的博客链接(那个网站是人家的...) :).
    10/27/2007

    Some Problems With Ubuntu 7.10


    这两天用 Ubuntu 7.10 和 Compiz-Fusion 遇到了几个小问题:

    1. Firefox 相关

    Ubuntu 自带的 Firefox 2.0.0.6 好像有很多问题,用起来总不舒服。很诡异的一点是,如果启用默认的 Ubuntu Extension for Firefox,无法打开 Windows Live Space 的博客页面。我起初还以为是 Feedburner 的统计图片无法显示造成的假死呢,但在卸载 Ubuntu Extension for Firefox 后一切正常,这就让人搞不明白了 Ubuntu team 做出来这个东西究竟是想干吗?

    2. Nvidia 显卡相关

    我使用的驱动是 Nvidia 官方最新的 for linux 驱动,单屏是没有任何问题的。但当使用双屏时,就是 TwinView,笔记本是 1280x800 的分辨率,外接 LCD 是 1280x1024 的分辨率,这时候笔记本屏幕会使用外接 LCD 的高度,造成的效果是在笔记本屏幕上看不到工具栏,因为工具栏在底部...所以只能用 Alt+Tab 切窗口。

    2. Compiz-Fusion 相关

    开启了 Compiz-Fusion 3D 特效之后,由于吸附作用,窗口的标题栏会不正常,经常会跑到桌面面板工具栏的后面,或者说不停的在尝试吸附,表现就是标题栏闪屏。

    在使用双屏时,第一次桌面立方体旋转需要很长时间,像死机了一样,我经常先切到 console 再重新切回 X window,但第一次旋转以后的旋转就很正常了,和单屏没什么区别,就是两个独立的屏一起转。

    另外,双屏还是很耗资源的,虽然我是 1.8G 双核 CPU, 1G 内存, 256M 显卡,在跑双屏时应用程序反应会稍微慢一点儿,不过并不很明显,还是在可以忍受的范围之内。感觉上在 Linux 上使用双屏没有在 Windows 上快,不过,嘿嘿,Windows 双屏只能算两个桌面,我的 Ubuntu 双屏可是 8 个桌面!!!

    10/21/2007

    Beijing Marathon 2007 and QQ


    早上来上班的路上发现知春路上多了很多人,每个路口都有站得笔直的警察和军人,偶尔还有几个保安,沿路二三十米一个带着治安巡逻红袖标的老大妈。本来我还为自己闯红灯惴惴,但想了一下查交通违规用不着这么大场面吧!到公司后马上到很少访问的新浪网上看了看新闻,哦,原来知春路是 2007 年北京马拉松的经过路段。反正是首都,总有这样那样的事情,比其它城市热闹多了。

    最近有些厌学情绪,我不知道是因为前几天熬夜太多了精神不好还是因为天气转凉要有个适应期。虽然没有学多少,但也没有闲着,我基本连静静思考问题的时间都没有。前两天还抽空装了一下 Ubuntu Linux,在很新的硬件上安装 Linux 果然是一种很痛苦的事情,我忽然怀念起自己原来台式机落后的 Gforce MX440 显卡了。虽然安装了 Ubuntu 7.10,不过我还没有怎么用,这几天回去以后还是 Windows 用的比较多。

    虽然我喜欢给别人宣扬开源的理念,可我从来不是一个彻底的 Linux 用户,从未把 Windows 从自己电脑上删除(曾经考虑过,但没实施),因为 Windows 也有很多让我不得不用的理由:我的 Samsung 手机数据传输,只有 Win 驱动;更包括很多 Office 文件,超星文件的使用问题;在中国的环境下,Linux 还没有适合中国用户的好的音乐播放器,好的下载软件,还有,现在对我来说很重要的一点是:好的语音聊天软件。不要和我提 Skype,在中科院(科学网)加南京大学(教育网+代理服务器)的条件下,还没有任何语音聊天软件比 QQ 更稳定(QQ 也不是很稳定)。所以我的 QQ 签名档是:"如果我QQ在线,说明正在和女朋友聊天,请勿打扰。闲时请使用 Gtalk: solrex{A}gmail.com 和我联系。"这是说真的,我只有在和女朋友语音聊天时候才会上 QQ,我们文字聊天也是使用 Gtalk 的。所以求求您了别对我的 QQ 签名档感到很好奇专门为此点开和我聊几句,请勿打扰就是请勿打扰,除非您觉得和我的关系非同一般。

    讲到 QQ,现在恐怕很多人都会想起"珊瑚虫"的案子,我对那个倒不是很在意,侵犯知识产权就是侵犯知识产权,不要扯上什么企业道德,总之侵权是犯法的,受害者就有权告,受害者告不告和要求怎样,和侵权人的行为性质没有关系。我想说的是最近发现 QQ 也在悄悄改变,包括:可以使用"自定义状态",像 MSN 和 Gtalk 的状态一样,会覆盖原始签名档;可以把 QQ 号与一个 Email 帐户绑定,然后对别人而言在所有显示 QQ 号码的地方都变成了 Email;据说 QQ Hummer 蜂鸟计划中有 Linux 版,希望能提供语音聊天功能,那样我又能减去一条不得不用 Win 的原因。

    最近我的脑子里面没有一点安安静静的想法,所以,生活记录到这里吧。
    10/19/2007

    Ubuntu 7.10 on my Dell Latitude D630


    最后更新时间:2007年10月19日20点25分

    作者:Wenbo Yang <wenbo.yang@simplnano.com>
    地址:http://blog.solrex.cn/articles/Ubuntu-7-10-on-my-Dell-Latitude-D630.html

    摘要

    这份文档主要描述了我在自己的 Dell Latitude D630 上安装 7.10 的过程,Ubuntu 7.10 现在在我的笔记本电脑上运行正常(准确说基本功能工作正常,因为我未做太多测试)。

    目录

    1. 介绍
    2. 安装
    3. 总结
    4. 计算机硬件信息
    5. 参考文章

    1. 介绍

    我最近买了一台 Dell Latitude D630 笔记本电脑。除了原装的 Windows XP Home Edition, 我已经在这台笔记本上安装 RHEL5,然后又安装了 Ubuntu 7.10 Linux 操作系统,下面是我安装 Gutsy Gibbon(Ubuntu 7.10) 的过程介绍。

    2. 安装

    [ 安装基本操作系统 ]
    # wget http://releases.ubuntu.com/7.10/ubuntu-7.10-alternate-i386.iso
    # wget http://archive.ubuntu.com/ubuntu/dists/gutsy/main/installer-i386/current/images/hd-media/initrd.gz
    # wget http://archive.ubuntu.com/ubuntu/dists/gutsy/main/installer-i386/current/images/hd-media/vmlinuz
    # cp vmlinuz initrd.gz /media/sda5
    # echo "title Gutsy Install Entry" >> /boot/grub/menu.lst
    # echo "    root (hd0,4)" >> /boot/grub/menu.lst
    # echo "kernel /vmlinuz root=/dev/ram ramdisk_size=40000 devfs=mount,dall" >> /boot/grub/menu.lst
    # echo "initrd /initrd.gz" >> /boot/grub/menu.lst
    # reboot
    以上下载地址可以换成任何 Ubuntu 镜像站点的下载地址。重新启动时在 Grub 的启动列表中选择 Gusty Install Entry,接下来就是标准的安装过程了。

    [ 修改更新源列表 ]
    添加以下行到 /etc/apt/source.list 中:
    deb http://ubuntu.cn99.com/ubuntu/ gutsy main restricted
    deb http://ubuntu.cn99.com/ubuntu/ gutsy-updates main restricted
    deb http://ubuntu.cn99.com/ubuntu/ gutsy universe
    deb http://ubuntu.cn99.com/ubuntu/ gutsy-updates universe
    deb http://ubuntu.cn99.com/ubuntu/ gutsy multiverse
    deb http://ubuntu.cn99.com/ubuntu/ gutsy-updates multiverse
    deb http://ubuntu.cn99.com/ubuntu/ gutsy-security multiverse
    deb http://ubuntu.cn99.com/ubuntu/ gutsy-security main restricted
    deb http://ubuntu.cn99.com/ubuntu/ gutsy-security universe

    在其它行前加上注释符 #

    [ 更新操作系统,安装工具软件包 ]
    $ sudo apt-get update
    $ sudo apt-get upgrade
    $ sudo apt-get install libc6 libc6-dev
    $ sudo apt-get install gcc-4.2
    $ sudo apt-get install g++- 4.2
    libc6 和 gcc 主要是为下面安装显卡驱动准备的。

    [ 下载 nVidia 最新显卡驱动 ]
    $ wget http://us.download.nvidia.com/XFree86/Linux-x86/100.14.09/NVIDIA-Linux-x86-100.14.09-pkg1.run

    [ 修改 root 用户密码 ]
    $ sudo passwd

    [ 安装显卡驱动 ]
    $ sudo reboot
    重新启动时在 Grub 的启动列表中选择 Ubuntu 7.10, kernel 2.6.22-14-generic (recovery mode),输入 root 用户密码,运行 NVIDIA-Linux-x86-100.14.09-pkg1.run,按照指示进行。安装成功后重新启动系统,在系统启动前跳出的对话框里选择配置显示效果,选择 1280x800 分辨率的基本配置,并在下方的使用宽屏选项栏打上勾。

    [ 解决 DVD±RW 驱动问题 ]
    $ cp /etc/modules /etc/modules.bak
    $ cp /etc/modules /tmp
    $ echo piix >> /tmp/modules
    $ sudo cp /tmp/modules /etc/modules
    $ sudo reboot
    这个我未曾尝试,因为还没有在 Linux 下刻录过光盘。

    [ 解决声卡驱动问题 ]
    因为 Dell Latitude D630 声卡版本比较新,用 Ubuntu 自带的 ALSA 驱动无法配置。解决办法是手工安装 ALSA 最新版本的 driver, lib 和 utils。你可以使用一个脚本 d630alsa.sh 来自动完成整个过程。

    $ wget http://www.iki.fi/kuparine/comp/d630/d630alsa.sh
    $ sudo sh d630alsa.sh
    参考网址: https://wiki.ubuntu.com/Gutsy_Intel_HD_Audio_Controller

    [ 安装中文输入法 ]
    首先在 System->Administration->Language Support 中选择安装中文支持,自动安装完中文支持以后:
    $ sudo apt-get install scim-bridge-agent
    $ sudo im-switch -s scim -z default
    在 /etc/X11/xinit/xinput.d/scim 中找到以下两行并更改:
    GTK_IM_MODULE=scim-bridge
    QT_IM_MODULE=xim
    如果 im-switch 不成功,可以手动将设置文件 copy 到 default 去
    $ sudo cp /etc/X11/xinit/xinput.d/default /etc/X11/xinit/xinput.d/default.bak
    $ sudo cp /etc/X11/xinit/xinput.d/scim /etc/X11/xinit/xinput.d/default
    $ sudo reboot

    [ 安装 Windows 中文字体 ]
    未在电脑上安装 Windows 操作系统者不需要此步骤,已安装者也可以选择跳过。我写了一个脚本做这个工作,可以从下面链接下载。

    $ wget http://share.solrex.cn/scripts/install_win_CN_fonts_to_linux.sh
    $ sudo sh install_win_CN_fonts_to_linux.sh
    重新登录 X window

    [ 安装 compiz-fusion 3D 桌面效果 ]
    $ sudo apt-get install compiz-fusion-plugins-main
    安装完成以后在 System->Preference->Appearance 中的 Visual Effects 中多出一项 Custom,选择以后,点右侧的 Preferences 配置效果。

    3. 总结

    硬件信息                                    Linux 下状态 备注
    Intel Core2 Duo T7100 @ 1.8 GHz          工作正常
    14.1" WXGA TFT (1280x800)          工作正常
    nVidia Corporation Quadro NVS 135M    工作正常      手工安装驱动程序    
    1 GB RAM (1 x 1024 MB DDR2 533 MHz)   工作正常   
    120 GB HDD (Hitachi HTS722016K9A300)  工作正常
    DVD±RW (PBDS DVD±RW DS-8W1P)          未验证        据说可以在 /etc/modules 增加 piix 解决.
    Broadcom NetXtreme BCM5755M Gigabit Ethernet 工作正常   
    Broadcom Corporation BCM94311MCG wlan mini-PCI 未验证
    Intel 82801H sound card (ICH8)        工作正常      Ubuntu 7.10 参见上面讲的处理方法.
    Memory card reader                    未验证
    Internal 56k modem                    未验证

    4. 计算机信息

    [ 所有 pci 设备 ]
    $ lspci
    00:00.0 Host bridge: Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub (rev 0c)
    00:01.0 PCI bridge: Intel Corporation Mobile PM965/GM965/GL960 PCI Express Root Port (rev 0c)
    00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Contoller #4 (rev 02)
    00:1a.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 02)
    00:1a.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 02)
    00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 02)
    00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 02)
    00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 02)
    00:1c.5 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 6 (rev 02)
    00:1d.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 02)
    00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 02)
    00:1d.2 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3 (rev 02)
    00:1d.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 02)
    00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev f2)
    00:1f.0 ISA bridge: Intel Corporation 82801HEM (ICH8M) LPC Interface Controller (rev 02)
    00:1f.1 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller (rev 02)
    00:1f.2 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA IDE Controller (rev 02)
    00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 02)
    01:00.0 VGA compatible controller: nVidia Corporation Quadro NVS 135M (rev a1)
    03:01.0 CardBus bridge: O2 Micro, Inc. Cardbus bridge (rev 21)
    03:01.4 FireWire (IEEE 1394): O2 Micro, Inc. Firewire (IEEE 1394) (rev 02)
    09:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5755M Gigabit Ethernet PCI Express (rev 02)
    0c:00.0 Network controller: Broadcom Corporation BCM94311MCG wlan mini-PCI (rev 01)

    以下省略了,只是写一下查看这些信息的命令
    [ 电池信息 ]
    $ less /proc/acpi/battery/BAT0/info
    [ CPU 信息 ]
    $ less /proc/cpuinfo
    [ 内存信息 ]
    $ less /proc/meminfo
    [ 内核消息 ]
    $ dmesg
    [ 加载的内核模块 ]
    $ lsmod
    [ X.org 设置文件(显示及输入设置)]
    $ less /etc/X11/xorg.conf

    5. 参考文章

        * HARDWARE Dell Latitude D630
        * My Ubuntu Installation
        * Ubuntu on my Dell Latitude D630



    10/17/2007

    A Windows Sniffer Based on WinPcap


    这几天相当之忙,好多事情要做,每天都要熬很晚,觉得都有点儿在崩溃的边缘了。

    才写完一个大作业,Windows 下基于 WinPcap 库的图形界面网络嗅探器。以前从来没有摸过 MFC 编程,忽然让写这种程序,都要头痛死了。十一回南京也没时间做,只有回来猛补,从网上抄些,自己写些,拼拼凑凑算是写出来一个很简单的网络嗅探器程序。不过我也不想再花工夫了,其实用 WinPcap 库写嗅探器简单到了极点,最难做的是图形界面,了解 MFC 编程对我价值不是很大,不准备再深入了。我把代码包放到我的网站上了,这里是链接地址:
    http://share.solrex.cn/MyWork/Eavesdrop_Windows_Sniffer_Based_on_Winpcap_VC6.rar
    有兴趣了解如何写网络嗅探器的可以下载下来看看。至于使用网络嗅探器,最好还是用 Ethereal,现在好像改名叫做 Wireshark 了,那才是真正强大的网络嗅探和协议分析工具,我们这种东西都是小儿科。

    今天抽空把上一篇博客里给出的在 Linux 下安装 Windows 中文字体的脚本稍微完善了下,也根据师兄的建议把源代码放在了网站上(用 Google translate 访问了一下我的 blogspot 才发现上面显示的代码全乱套了)
    http://share.solrex.cn/scripts/install_win_CN_fonts_to_linux.sh
    ,修改了一下上一篇博客内容。之所以喜欢把代码放在文章里主要是经常搜索一些示例代码时发现源代码的下载链接不能使用,还是放在文章里一份拷贝比较有利于知识共享。

    估计这个星期还会很忙,有一个对 DES 进行差分攻击的报告,有一个希腊哲学史方面的课程论文,还有很多书和 paper 要看。就算我不兼职,研究生生活也并不轻松啊...

    10/13/2007

    Using Windows Fonts in Ubuntu on Duo-System-Installed Computer

    下 面的脚本使用 windows 自带字体美化 Ubuntu Linux 字体,主要是将软件中文字体使用宋体,终端使用黑体替换。脚本源程序可以在 http://share.solrex.cn/scripts/install_win_CN_fonts_to_linux.sh 下载到。

    首先确保 windows 系统所在分区被挂载到 /media 目录下将以下内容保存为脚本文件:install_win_CN_fonts_to_linux.sh#!/bin/bash
    check_answer()
    {
        case $1 in
            y|Y|Yes|yes|YES)
                return 0;
                ;;
            n|N|No|no|NO)
                return 1;
                ;;
            *) echo "Answer either yes or no, default is yes"
                return 2
                ;;
        esac
    }

    LIN_FONTS_DIR=/usr/share/fonts/zh_CN/TrueType
    LANG_SEL_FILE=/etc/fonts/language-selector.conf
    SEARCH_DIR=/media

    echo -n "This script is for installing Windows Chinese fonts to Linux on a dual-OS-installed computer. And the writer doesn't promise it will work on your system. Do you want to continue?(y/n)[y]:"
    read ANS_STR
    : ${ANS_STR:="y"}
    check_answer $ANS_STR
    ANS=$?
    if [ $ANS -ne 0 ]; then
        echo "Exit."
        exit
    fi

    echo -n "There might be license problems, i.e. you have no permission to use Windows fonts in other program except Windows OS. Do you want to continue?(y/n)[y]:"
    read ANS_STR
    : ${ANS_STR:="y"}
    check_answer $ANS_STR
    ANS=$?
    if [ $ANS -ne 0 ]; then
        echo "Exit."
        exit
    fi

    echo -n "You run this script with root account or \"sudo\" command?(y/n)[y]:"
    read ANS_STR
    : ${ANS_STR:="y"}
    check_answer $ANS_STR
    ANS=$?
    if [ $ANS -ne 0 ]; then
        echo "Exit."
        exit
    fi

    echo -n "You mounted Windows System partation \"C:\\\" to /media directory?(y/n)[y]:"
    read ANS_STR
    : ${ANS_STR:="y"}
    check_answer $ANS_STR
    ANS=$?
    if [ $ANS -ne 0 ]; then
        echo "Exit."
        exit
    fi

    echo "Searching for windows's fonts directory..."
    echo "That may take a few minutes, please wait."
    WIN_FONTS_DIR=`echo $(find $SEARCH_DIR -name simsun.ttc -type f) | sed s/simsun.ttc//g`
    if [ -d $WIN_FONTS_DIR ]; then
        while true; do
            echo "Windows fonts dir found! Your windows fonts directory is: "
            echo -n "\"$WIN_FONTS_DIR\" Is it right?(y/n)[y]:"
            read ANS_STR
            : ${ANS_STR:="y"}
            check_answer $ANS_STR
            ANS=$?
            if [ $ANS -eq 0 ]; then
                break
            elif [ $ANS -eq 1 ]; then 
                echo "Please enter path to your windows fonts dir?"
                read ANS_STR
                if [ -d $ANS_STR ]; then
                    WIN_FONTS_DIR=$ANS_STR
                    break
                else
                    echo "Your input is not a dir. Exit."
                    exit
                fi
            else
                echo "Unrecognized input."
            fi
        done
    else
        echo "Can not find windows fonts directory. "
        echo -n "Please enter path to your windows fonts dir:"
        read ANS_STR
        if [ -d $ANS_STR ]; then
            WIN_FONTS_DIR=$ANS_STR
        else
            echo "Your input is not a dir. Exit."
            exit
        fi
    fi

    echo "Entering $WIN_FONTS_DIR"
    cd $WIN_FONTS_DIR

    echo "Creating Linux fonts directory: $LIN_FONTS_DIR..."
    mkdir -p $LIN_FONTS_DIR
    if [ $? -ne 0 ]; then
        echo "Creating Linux fonts dir failed. Exit."
        exit
    fi

    echo "Copying windows fonts to linux fonts dir... sim*|tahoma|tohomabd.ttf"
    cp sim* SimSun18030.ttc tahoma.ttf tahomabd.ttf $LIN_FONTS_DIR
    if [ $? -ne 0 ]; then
        echo "Copying windows fonts to linux fonts dir failed. Exit."
        exit
    fi

    echo "Changing font files' access permissions.."
    chmod 644 $LIN_FONTS_DIR/*

    echo "Entering $LIN_FONTS_DIR"
    cd $LIN_FONTS_DIR

    echo "Creating an index of scalable font files in $LIN_FONTS_DIR for X..."
    mkfontscale
    if [ $? -ne 0 ]; then
        echo "Creating an index of scalable font files for X failed. Exit."
        exit
    fi

    echo "Creating an index of X font files in $LIN_FONTS_DIR"
    mkfontdir
    if [ $? -ne 0 ]; then
        echo "Creating an index of X font files in $LIN_FONTS_DIR failed. Exit."
        exit
    fi

    echo "Creating an index of FreeType font files in $LIN_FONTS_DIR"
    fc-cache $LIN_FONTS_DIR
    if [ $? -ne 0 ]; then
        echo "Creating an index of FreeType font files in $LIN_FONTS_DIR failed. Exit."
        exit
    fi

    echo "Backing up $LANG_SEL_FILE"
    if [ -f $LANG_SEL_FILE ]; then
        cp $LANG_SEL_FILE $LANG_SEL_FILE.bak
    fi

    echo "Generating new $LANG_SEL_FILE... for language select"
    echo '
    <fontconfig>
      <alias>
        <family>serif</family>
          <prefer>
            <family>Bitstream Vera Serif</family>
            <family>SimSun</family>
            <family>DejaVu Serif</family>
            <family>AR PL ShanHeiSun Uni</family>
            <family>AR PL ZenKai Uni</family>
          </prefer>
      </alias>
      <alias>
        <family>sans-serif</family>
          <prefer>
            <family>Bitstream Vera Sans</family>
            <family>SimSun</family>
            <family>DejaVu Sans</family>
            <family>AR PL ShanHeiSun Uni</family>
            <family>AR PL ZenKai Uni</family>
          </prefer>
      </alias>
      <alias>
        <family>monospace</family>
          <prefer>
            <family>DejaVu Sans Mono</family>
            <family>Bitstream Vera Sans Mono</family>
            <family>SimHei</family>
        </prefer>
      </alias>

    <match target="font" >
      <test name="family" compare="contains" >
        <string>Song</string>
        <string>Sun</string>
        <string>Kai</string>
        <string>Ming</string>
      </test>
      <test compare="more_eq" target="pattern" name="weight" >
        <int>180</int>
      </test>
      <edit mode="assign" name="embolden" >
        <bool>true</bool>
      </edit>
    </match>

    <match target="font" >
      <test name="family" compare="contains" >
        <string>Song</string>
        <string>Sun</string>
        <string>Kai</string>
        <string>Ming</string>
      </test>
      <edit name="globaladvance">
        <bool>false</bool>
      </edit>
      <edit name="spacing">
        <int>0</int>
      </edit>
      <edit name="hinting">
        <bool>true</bool>
      </edit>
      <edit name="autohint">
        <bool>false</bool>
      </edit>
      <edit name="antialias" mode="assign">
        <bool>true</bool>
      </edit>
      <test name="pixelsize" compare="less_eq">
        <int>18</int>
      </test>
      <edit name="antialias" mode="assign" >
        <bool>false</bool>
      </edit>
    </match>

    <match target="pattern">
      <test name="family">
        <string>SimSun</string>
        <string>SimSun-18030</string>
        <string>AR PL ShanHeiSun Uni</string>
        <string>AR PL New Sung</string>
        <string>MingLiU</string>
        <string>PMingLiU</string>
      </test>
      <edit binding="strong" mode="prepend" name="family">
        <string>Tahoma</string>
        <string>Verdana</string>
      </edit>
    </match>

    <match target="pattern">
      <test name="family">
        <string>宋体</string>
      </test>
      <edit name="family" mode="assign">
        <string>SimSun</string>
      </edit>
    </match>
    <match target="pattern">
      <test name="family">
        <string>新宋体</string>
      </test>
      <edit name="family" mode="assign">
        <string>SimSun</string>
      </edit>
    </match>
    <match target="pattern">
      <test name="family">
        <string>仿宋_GB2312</string>
      </test>
      <edit name="family" mode="assign">
        <string>FangSong_GB2312</string>
      </edit>
    </match>
    <match target="pattern">
      <test name="family">
        <string>楷体_GB2312</string>
      </test>
      <edit name="family" mode="assign">
        <string>KaiTi_GB2312</string>
      </edit>
    </match>
    <match target="pattern">
      <test name="family">
        <string>黑体</string>
      </test>
      <edit name="family" mode="assign">
        <string>SimHei</string>
      </edit>
    </match>
    </fontconfig> ' > $LANG_SEL_FILE
    echo "Finished. Please quit your X session and relogin."
    echo "If you have problems on start X(sometimes happened on Ubuntu 7.04.), please delete $LIN_FONTS_DIR and copy the backuped $LANG_SEL_FILE.bak to $LANG_SEL_FILE. Then do \"fc-cache\" with no options. That may work."


    更改文件的权限:
    sudo chmod u+x install_win_CN_fonts_to_linux.sh
    执行:
    sudo ./install_win_CN_fonts_to_linux.sh

    登出 Xwindow,再重新登录即可。

    10/7/2007

    End of Golden Week


    长假结束了,要乘今天晚上的 T66 回北京。唉,虽然基本算是哪里都没去,但还是好累,大概是因为住同学租的房子,没有在校园里的缘故吧。

    这几天主要做的事情就是陪女朋友,然后到丹阳配了副眼镜,剩下的好像没干什么。

    回去也比较痛苦,因为貌似有好多作业没写...尤其是一个网络嗅探器的大作业。所以要赶紧买个电脑,把程序赶出来,估计后面一个星期要有几天不用睡觉了~~~