'분류 전체보기'에 해당되는 글 188건

Posted on 2018/09/28 11:55
Filed Under Linux/설정방법

DNS server, DNS service  

출처 : https://schooloffreelancing.blogspot.com/2017/11/asterisk-freepbx-install-into-ubuntu.html

apt-get -y autoremove
apt-get -y update
apt-get -y upgrade
# Some Utils
apt-get install -y curl vim-nox
# PJSIP
apt-get install -y make gcc g++ binutils sudo git
cd /usr/src
git clone https://github.com/asterisk/pjproject.git
cd /usr/src/pjproject
CFLAGS='-DPJ_HAS_IPV6=1' ./configure --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr
make dep 
make
make install
ldconfig
ldconfig -p | grep pj
# Asterisk 13
apt-get install -y libtool pkg-config libnewt-dev subversion
apt-get install -y libncurses5-dev uuid-dev libjansson-dev libxml2-dev libsqlite3-dev
apt-get install -y libmysqlclient-dev 
apt-get install -y unixodbc-dev libmyodbc
apt-get install -y libssl-dev libcurl4-openssl-dev libgnutls28-dev libsrtp0-dev
apt-get install -y bison flex
apt-get install -y sox lame flac mpg123 libmpg123-dev libogg-dev libvorbis-dev libspeex-dev libspeexdsp-dev libasound2-dev
apt-get install -y libiksemel-dev libiksemel-utils 
apt-get install -y libspandsp-dev
apt-get install -y libical-dev libneon27-dev 
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar zxvf asterisk-13-current.tar.gz
cd asterisk-*
# contrib/scripts/install_prereq install
contrib/scripts/get_mp3_source.sh
./configure
make menuselect.makeopts
menuselect/menuselect --enable-category MENUSELECT_ADDONS menuselect.makeopts
menuselect/menuselect --enable CORE-SOUNDS-EN-GSM --enable MOH-OPSOUND-WAV --enable EXTRA-SOUNDS-EN-GSM --enable cdr_mysql menuselect.makeopts
menuselect/menuselect --disable app_mysql --disable app_setcallerid --disable func_audiohookinherit menuselect.makeopts
make
make install
make config
make samples
ldconfig
ldconfig -p | grep asterisk
systemctl disable asterisk.service
cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
tar xvf asterisk-core-sounds-en-wav-current.tar.gz
rm -f asterisk-core-sounds-en-wav-current.tar.gz
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
rm -f asterisk-extra-sounds-en-wav-current.tar.gz
# Wideband Audio download 
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
rm -f asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-core-sounds-en-g722-current.tar.gz
rm -f asterisk-core-sounds-en-g722-current.tar.gz
useradd -m asterisk
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
# FreePBX 13
export DEBIAN_FRONTEND=noninteractive
apt-get install -y apache2 mysql-server mysql-client php5 php5-curl php5-cli php5-mysql php5-gd php-pear unixodbc
rm /var/www/html/index.html
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
service apache2 restart
cat >> /etc/odbcinst.ini << EOF
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1
 
EOF
cat >> /etc/odbc.ini << EOF
[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/run/mysqld/mysqld.sock
option=3
 
EOF
cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz
tar vxfz freepbx-13.0-latest.tgz
rm -f freepbx-13.0-latest.tgz
cd /usr/src/freepbx
rm /etc/asterisk/*.conf
./start_asterisk start
./install -n
cat >> /etc/systemd/system/freepbx.service << EOF
[Unit]
Description=FreePBX VoIP Server
After=mysql.service
 
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start
ExecStop=/usr/sbin/fwconsole stop
 
[Install]
WantedBy=multi-user.target
 
EOF
systemctl enable freepbx.service
systemctl start freepbx.service
systemctl status freepbx.service
fwconsole chown
fwconsole reload
fwconsole moduleadmin installall
fwconsole moduleadmin upgradeall
fwconsole chown
fwconsole reload
fwconsole moduleadmin uninstall dahdiconfig
fwconsole moduleadmin delete dahdiconfig
fwconsole moduleadmin uninstall sipstation
fwconsole moduleadmin delete sipstation
fwconsole moduleadmin uninstall digium_phones
fwconsole moduleadmin delete digium_phones
fwconsole moduleadmin uninstall cxpanel
fwconsole moduleadmin delete cxpanel
fwconsole moduleadmin uninstall firewall
fwconsole moduleadmin delete firewall
fwconsole moduleadmin upgradeall
fwconsole chown
fwconsole reload
fwconsole chown
2018/09/28 11:55 2018/09/28 11:55

Posted on 2018/04/23 19:30
Filed Under Linux/설정방법

DNS server, DNS service  

원격 접속 가능한 호스트 및 사용자 확인



[root@company bin]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 561388
Server version: 5.0.51-log Source distribution
 
 
 
mysql> select HOST, USER, Password FROM mysql.user;
+-----------------+-------+-------------------------------------------+
| HOST            | USER  | Password                                  |
+-----------------+-------+-------------------------------------------+
| localhost       | root  | *(생략)                           | 
| company         | root  |                                           | 
| 127.0.0.1       | root  |                                           | 
| localhost       |       |                                           | 
| company         |       |                                           | 
| localhost       | news  | *(생략)                                | 
| 211.200.200.200 | news  | (생략)                                     | 
| 100.200.100.100 | news  | (생략)                                      | 
| 192.168.100.110 | news  | (생략)                                      | 
+-----------------+-------+-------------------------------------------+
 
9 rows in set (0.02 sec)


위 경우 HOST에 명시된 호스트에서만 접속 가능.

따라서 사용자 추가.


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| mysql              | 
| company            | 
+--------------------+
3 rows in set (0.01 sec)
 
mysql> use mysql
Database changed
 
mysql> insert into user (host,user,password) 
values('%','news',password('newspasswd'));
Query OK, 0 rows affected (0.02 sec)
 
mysql> GRANT all privileges on *.* to 'news'@'%' 
identified by 'newspasswd' ;
Query OK, 0 rows affected (0.02 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
 
 
mysql> select HOST, USER, Password FROM mysql.user;
+-----------------+-------+-------------------------------------------+
| HOST            | USER  | Password                                  |
+-----------------+-------+-------------------------------------------+
| localhost       | root  | *7540F67EE4(생략)                         | 
| company         | root  |                                           | 
| 127.0.0.1       | root  |                                           | 
| localhost       |       |                                           | 
| company         |       |                                           | 
| localhost       | news  | *7540F67EE4                               | 
| 211.200.200.200 | news  | 49d7                                      | 
| 100.200.100.100 | news  | 49d7                                      | 
| 192.168.100.110 | news  | 49d7                                      | 
| %  | news  | *7540F67EE4                               | 
+-----------------+-------+-------------------------------------------+
10 rows in set (0.02 sec)
 

단 MySQL 5.7에서는 Insert 명령어를 아래와 같이 변경해야 함.
insert into user(host,user,authentication_string,ssl_cipher,x509_issuer,x509_subject) values ('%', 'news', password('password'),'','','');


호스트를 %로 할경우 어떤 호스트에서든 접속 가능.


이렇게 하고도... 외부에서 접속이 안될 경우

1. OS 방화벽 (리눅스 방화벽 확인 ) 해제 - ufw disable
2. MySQL 설정 파일 "my.cnf" (mysqld.cnf) 에, bind-address=127.0.0.1 로 되어 있는 것을 "0.0.0.0" 으로 변경 후, 
3. MySQL 재시작

2018/04/23 19:30 2018/04/23 19:30

Posted on 2018/04/02 15:28
Filed Under Linux/장애처리

DNS server, DNS service  

우분투 16.04 버전은 systemd 기반으로 PID들이 관리된다,
rc.local을 부득이 하게 사용할 일이 생겨 사용하려 했으나 활성화가 안되어 있어서 활성화 방법을 찾아서 기록

 

/lib/systemd/sytem/rc-local.service 을 수정한다.

 

가장 하단에 

 

more..

 


​위 와 같이 추가 시켜준 뒤 

more..

 

​rc.local 서비스를 활성화 시켜준다.

Install을 추가시켜주지 않고 활성화를 시켜주려 하면, 해당 부분이 없어 활성화가 되지 않는다.

 

rc.local이 제데로 동작하는지 테스트는 서비스 재시작 뒤 확인 해주면 된다.

more..

 

​정상적으로 동작한다면 

 

more..


active (활성화) 되었다고 표시되며, 하단에 로그도 확인이 가능하다.

2018/04/02 15:28 2018/04/02 15:28

Posted on 2018/03/08 17:43
Filed Under Programming/C,C++

DNS server, DNS service  

출처: http://bbolmin.tistory.com/65 


Stack Smashing Protector은 gcc 4.1버전 부터 있는 stack overflow를 방지하기 위한 컴파일러 옵션이다.

 

gcc 4.6.1버전에서 컴파일 후 overflow가 발생하는 프로그램을 실행시켜 보니 다음과 같이 stack smashing detected가 뜨는 것을 확인 할 수 있다.

SSP 끄기 : -fno-stack-protector

SSP를 모든 함수에 설치 : -fstack-protector-all (원래는 일정 크기의 char배열이 있는 함수에만 적용됨)


SSP의 기능을 살펴보자

1. 로컬 변수 재배치

2. 로컬 변수전에 포인터 배치

3. canary 삽입

 

1. 로컬 변수 재배치

 

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

 

void main(int argc, char *argv[])

{

    int check=0;
    char buf[10];

    strcpy(buf, argv[1]);

    if(check==0)
        exit(0);

    printf("check : %d\n", check);

}

buf를 오버플로우시켜서 check값을 바꿀 수 있을 것이다. 하지만 SSP는 스택에서 char배열을 제일 높은 곳으로 올려 다른 변수 값이 변조되는 것을 막는다.

 

 

2. 로컬 변수전에 포인터 배치

 

void test(char *arg)

{

char buf[10];

strcpy(buf, arg);

}

위와 같이 포인터가 있을 때 buf를 오버플로우 시켜서 test함수의 파라미터로 전달된 포인터 arg값을 바꿀 수 있을 것이다. 하지만 SSP는 arg포인터를 buf아래 쪽에 두어서 변조되는 것을 막는다.

 

 

 

3. canary 삽입

 

------------

|       ret     |

------------

|      ebp     |

------------

|   canary  |

------------

|       buf     |

------------

 

stack guard처럼 canary를 두어 ret변조를 탐지한다. 이 때 canary는 ebp와 buf 사이에 넣는다. canary 값은 1) random, 2) terminator, 3) null 을 사용하여 우회하는 것을 방지한다. canary 변조를 탐지 했을 때 맨위 그림와 같이 stack-smashing-detected 메시지를 띄어준다. (변조 탐지시 __stack_chk_fail함수를 호출)

 

2018/03/08 17:43 2018/03/08 17:43

Posted on 2018/03/08 17:14
Filed Under Programming/Tools

DNS server, DNS service  

에러 메시지 
Unable to open 'raise.c': File not found (file:///build/glibc-Cl5G7W/glibc-2.23/sysdeps/unix/sysv/linux/raise.c).

이 경우 우선 glibc 를 소스까지 다운로드



Building glibc without installing

To build glibc without installing you can do the standard configure and make e.g.

$ mkdir $HOME/src
$ cd $HOME/src
$ git clone git://sourceware.org/git/glibc.git
$ mkdir -p $HOME/build/glibc
$ cd $HOME/build/glibc
$ $HOME/src/glibc/configure --prefix=/usr
$ make

Do not run make install.



이후 아래 설명을 참고하여, 찾고자 하는 링크 위치를 심볼릭 링크 걸어주면 해결






To do full source code debugging of the C library on Ubuntu, you need to:

1) install the debuginfo version of libc6.

It's probably already installed, but in case it isn't, run sudo apt install libc6-dbg.

2) download the source code corresponding to the installed version of the C library.

First, create a directory anywhere - I'll use /opt/src here. Then do the following:

sudo apt install dpkg-dev
cd /opt/src
apt source libc6
find $PWD -maxdepth 1 -type d -name 'glibc*'

Remember this name - it'll be something like /opt/src/glibc-2.23

Now, run gdb, run your program until it stops, and at the gdb prompt do this:

(gdb) info source
Current source file is ../sysdeps/unix/sysv/linux/raise.c
Compilation directory is /build/glibc-KM3i_a/glibc-2.23/signal

So gdb is expecting the source code to be in a directory that's different from where we put it. There are two ways to fix this:

a) move or use a symlink so that the source code is (or appears to be) in /build/glibc-KM3i_a/glibc-2.23 .

b) tell gdb how to substitute the correct source directory pathname: 

  (gdb) set substitute-path /build/glibc-KM3i_a/glibc-2.23 /opt/src/glibc-2.23

Now, go back to your frame, and gdb should show the source code line:

(gdb) frame 1
#1 0xb7e2fea9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
         return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
2018/03/08 17:14 2018/03/08 17:14

Posted on 2018/03/07 15:02
Filed Under Programming/Tools

DNS server, DNS service  

다음의 세개의 글 참조

#1 https://www.thegeekstuff.com/2014/04/gdbserver-example
#2 https://medium.com/@spe_/debugging-c-c-programs-remotely-using-visual-studio-code-and-gdbserver-559d3434fb78
#3 https://code.visualstudio.com/docs/languages/cpp#_windows-debugging-with-gdb 


How to Debug Programs on Remote Server using GDBServer Example

GDBRemote debugging is the process of debugging a program running on a different system (called target) from a different system (called host).

To start remote debugging, a debugger running on host machine connects to a program which is running on the target via network.

The debugger in the host can then control the execution of the program on the remote system and retrieve information about its state.

Remote debugging is often useful in case of embedded applications where the resources are limited.

In this tutorial, we will see how we can debug programs running on a different system using GDB Server.

If you are new to GDB, you should first understand how to use GDB to debug C program.

We need the following two utilities to perform a remote debugging.

  • gdbserver – Run this on your target system
  • GDB – Execute this on your host system to connect to your target system

GDB and gdbserver communicate via either a serial line or a network, using the standard gdb remote serial protocol.

1. Install gbdserver on Target System

Target machine is the one which is running the program which you have to debug. You need to have the “gdbserver” executable on the target machine.

$ sudo apt-get install gdbserver

To do remote debugging, start your program using the gdbserver. gdbserver then automatically suspends the execution of your program at its entry point, and it waits for a debugger to connect to it. gdbserver doesn’t need the symbols from your program to debug. So you can strip symbols out of your program binary to save space.

$ gdbserver localhost:2000 my_prg 

Process program created; pid = 2045
Listening on port 2000

The above command suspend the execution on my_prg, and waits for a debugger to connect to it on port 2000.

2. Launch gdb on Host System

The executable file and the libraries in the host, must exactly match the executable file and libraries on the target, with an exception that the target binary symbols can be stripped. You can also load the symbols separately in the host using “file” command in gdb.

Run GDB on the host.

$ gdb my_prg
(gdb)

Use “target remote” to connect to the target system.

(gdb) target remote 192.168.1.10:2000

Now you can run the normal gdb commands, as if you are debugging a local gdb program.

3. Remote Debugging Demo Example

The following C program example will be used to demonstrate the remote debugging.

#include <stdio.h>

int power(int,int);

int main() {

        int i;
        printf("Program to calculate power\n");
        for (i=0;i<10;i++)
                printf("%d %d\n",i, power(2,i));
        return 0;
}

int power (int base, int n) {

        int i,p;
        p=1;
        for (i=1; i<=n; i++)
                p = p*base;
        return p;
}

$ cc -g -o my_prg power.c

On Target Machine,

$ gdbserver localhost:2000 my_prg
Process my_prg created; pid = 20624
Listening on port 2000

On Host Machine,

$ gdb my_prg

(gdb) target remote 192.168.1.10:2000
Remote debugging using 192.168.1.10:2000
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x00007ffff7dddaf0 in ?? () from /lib64/ld-linux-x86-64.so.2
(gdb) b main
Breakpoint 1 at 0x400550
(gdb) continue 
Continuing.

Breakpoint 1, 0x0000000000400550 in main ()

Now we have connected the gdb for remote debugging. In the last example, we have put a breakpoint in main() function. If we continue our program, the output of the program will be printed in the target machine.

On Host:

(gdb) continue

On Target:

Remote debugging from host 192.168.1.20
Program to calculate power
0 1
1 2
2 4
3 8
4 16
5 32
6 64
7 128
8 256
9 512

Child exited with status 0
GDBserver exiting

4. Attach gdb to a Running Process on Target

First you have to find the process ID of the running process in target.

On Host,

(gdb) attach 3850

Now the gdb will suspend the process 3850 in the target and you can debug the program using normal gdb commands.

5. Launch gdbserver in Multi-process Mode

In the previous demo, you would have noticed that once the program executed successfully, the gdbserver also got exited. In real-time, you may want to debug multiple programs remotely, and you may not want to start the gdbserver every time with different program names. Do the following to achieve that.

On Target, run the gdbserver with –multi and without a program name.

$ gdbserver --multi localhost:2000
Listening on port 2000

On Host,

$ gdb

(gdb) target extended-remote 192.168.1.10:2000
Remote debugging using 192.168.1.10:2000

(gdb) (gdb) set remote exec-file /my_prg
(gdb) file /my_prg 
Reading symbols from /my_prg...(no debugging symbols found)...done.
(gdb) b main
Note: breakpoint 1 also set at pc 0x400550.
Breakpoint 2 at 0x400550
(gdb) run
Starting program: /my_prg
Breakpoint 1, 0x0000000000400550 in main ()

From the above snippet,

  1. ‘target extended-remote’ is used to run gdbserver in multi process mode.
  2. ‘set remote exec-file /my_prg’ is used to set the program which you want to debug in the target.
  3. ‘file /my_prg’ is used to load the debugging symbols from the program in the host.
  4. ‘b main’ is used to set breakpoint at main() function.
  5. ‘run’ is used to run the program, which stops at the breakpoint main().

Note: In the above case, the executable “my_prg” is present under “/” on both target and host.

Now either you can ‘continue’ or ‘detach’ the program from debugging. Still the gdbserver will not exit in the target machine, so you can change the ‘remote exec-file’ at any time, and debug a different set of program.





Debugging C/C++ Programs Remotely Using Visual Studio Code and gdbserver

If you’re like me and prefer using a GUI to a command line for setting breakpoints, stepping through code, and inspecting values as your program runs, here is how you can set up VSCode and gdbserver to edit and debug your code locally while running it on a remote server.

Background: I’m working on an assignment for CSC469 at the University of Toronto, and it will only compile and run on the university’s teaching lab machines. My goal was to be able to edit and debug locally in a familiar editor while compiling and running on the remote teaching lab machines.

Note: I’m using macOS Sierra locally, with the remote machine running Ubuntu 14.04, but this guide should work with any Unix system. (Sorry, Windows users).

Note: Commands to be run on the remote machine are prefixed with remote$and local commands are prefixed with local$ .

1. Install gdbserver on the remote machine

Installation varies by system. On Debian/Ubuntu, you can do:

remote$ apt-get install gdbserver

Since students are not allowed to install software via apt on the U of T machines, I used Linuxbrew to install it to my user folder:

remote$ brew install gdbserver

2. Install gdb on your local machine

On macOS Sierra, I used Homebrew to install gdb:

local$ brew install gdb --with-all-targets

Note: The --with-all-targets option is important; without it, you won’t be able to debug on a remote machine with a different OS or architecture than your local machine.

3. Test gdb

At this point, you should be able to run gdbserver on the remote machine and connect to it from your local gdb CLI. I’ll use the -L option of ssh to forward local port 9091 connections to the remote port 9091:

local$ ssh -L9091:localhost:9091 user@remote
remote$ cd ./myproject/ && make
remote$ gdbserver :9091 ./myprogram

(Port 9091 is arbitrary; use any port number you like)

Leave that command running in a terminal window; it will wait until gdb connects before running ./myprogram .

In another terminal window on your local machine, run gdb:

local$ gdb
GNU gdb (GDB) 7.12
Copyright (C) 2016 Free Software Foundation, Inc.
...
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb)

Then connect to the gdbserver instance:

(gdb) target remote localhost:9091
Remote debugging using localhost:9091
...
(gdb)

To verify things are working, you can run various gdb commands like info sources , or set a breakpoint with break . Use continue to run ./myprogram .

4. codesign gdb

VSCode prevents you from running gdb unless it’s signed; follow these steps to ensure it’s signed.

5. Synchronize local and remote file systems

You may have noticed that, for basic functionality, the gdb CLI on your local machine doesn’t need to be provided any information about the program or its source code except for the host and port on which gdbserver is running. But there are two big reasons why you’ll want to keep your local and remote project directories in sync:

  • Viewing source code in the gdb CLI (i.e. list).
  • The VSCode C/C++ extension requires you to provide the path to the compiled executable to launch gdb. (The "program" field in launch.json).

I opted to use sshfs since it required the least server-side setup, but you could use NFS, rsync, or other alternatives.

Using sshfs, mount the remote project folder locally:

local$ mkdir ./myproject
local$ sshfs user@remote:myproject ./myproject

Note: on macOS, you can later unmount the directory with umount ./myproject. On Linux, use fusermount -u ./myproject.

6. Configure Visual Studio Code

Open your newly-mounted project ./myproject/ in VSCode, then open .vscode/launch.json or create it if it doesn’t exist:

{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/myprogram",
"miDebuggerServerAddress": "localhost:9091",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "gdb"
},
"windows": {
"MIMode": "gdb"
}
}
]
}

This configuration will make it so clicking “C++ Launch” will run gdb similar to:

local$ gdb ./myprogram
...
(gdb) target remote localhost:9091

7. Write a script to compile your program and launch gdbserver

Ideally, you’d want to be able to run a single command or click a single button to compile & debug your program.

This might be possible to do via VSCode tasks and the preLaunchTask option in launch.json, but I was not able to put together a simple solution using those.

Instead I wrote a quick-and-dirty shell script prepare_remote_debug.sh :

# Kill gdbserver if it's running
ssh user@remote killall gdbserver &> /dev/null
# Compile myprogram and launch gdbserver, listening on port 9091
ssh \
-L9091:localhost:9091 \
user@remote \
"zsh -l -c 'cd myproject && make && gdbserver :9091 ./myprogram'"

8. Start debugging

Here is your new workflow:

  1. Edit some code.
  2. Run ./prepare_remote_debug.sh in a terminal window. Your program’s output will appear here.
  3. Set some breakpoints.
  4. Run “C++ Launch”.
  5. Step through your code in VSCode’s debugger.
  6. Repeat.

That’s it! I hope this helps someone, and let me know if it can be simplified even further.






C/C++ for VS Code (Preview)

C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development using VS Code on Windows, Linux, and macOS. The extension is still in preview and our focus is code editing, navigation, and debugging support for C and C++ code everywhere that VS Code runs.

cpp hero

If you just want a lightweight tool to edit your C++ files, Visual Studio Code is a great choice but if you want the best possible experience for your existing Visual C++ projects or debugging on Windows, we recommend you use a version of Visual Studio such as Visual Studio Community.

If you run into any issues or have suggestions for the Microsoft C/C++ extension, please file issues and suggestions on GitHub. If you haven't already provided feedback, please take this quick survey to help shape this extension for your needs.

Note for Linux users: The C/C++ extension works on 64-bit Linux distros that have glibc 2.18 or later installed.

Getting Started

To install the Microsoft C/C++ extension:

  • Open VS Code.
  • Click the Extensions View icon on the Sidebar.
  • Search for c++.
  • Click Install, then click Reload.

cpp extension

With the C/C++ extension installed, open a folder that contains your C/C++ source code. VS Code will place various settings files into a .vscode subfolder.

Note: The C/C++ extension does not include a C++ compiler or debugger. You will need to install these tools or use those already installed on your computer. Popular C++ compilers are MinGW for Windows, XCode for macOS, and GCC on Linux. Also make sure your compiler executable is on your platform path for VS Code to find.

IntelliSense

To enable code completion and navigation, you will need to generate a c_cpp_properties.json file:

  • Find any green squiggle in a source file (for example, an #include statement) and set the cursor on the line.
  • Click the lightbulb that appears in the left gutter.
  • Click Update "browse.path" setting.

browse path light bulb

This will generate a c_cpp_properties.json file that allows you to add additional browse paths to properly enable code navigation and auto-completion. The generated c_cpp_properties.json file has sections for different operating systems, make sure you update the appropriate settings for your current platform.

Below you can see that the MinGW C++ include path has been added to browse.path for Windows:

{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE"
    ],
    "intelliSenseMode": "msvc-x64",
    "browse": {
        "path": [
            "${workspaceFolder}",
            "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
        ],
        "limitSymbolsToIncludedHeaders": true,
        "databaseFilename": ""
    }
}

Note: You can also generate or edit a c_cpp_properties.json file with the C/Cpp: Edit Configurations command from the Command Palette (Ctrl+Shift+P).

Building your code

If you want to build your application from VS Code, you will need to generate a tasks.json file:

  • Open the Command Palette (Ctrl+Shift+P).
  • Select the Tasks: Configure Tasks... command, click Create tasks.json file from templates, and you will see a list of task runner templates.
  • Select Others to create a task which runs an external command.
  • Change the command to the command line expression you use to build your application (for example g++).
  • Add any required args (for example -g to build for debugging).
  • You can also change the label to be more descriptive.

You should now see a tasks.json file in your workspace .vscode folder that looks something like:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build hello world",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g", "helloworld.cpp"
            ]
        }
    ]
}

If you'd like to be able to build your application with Tasks: Run Build Task (Ctrl+Shift+B), you can add it to the build group.

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build hello world",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g", "helloworld.cpp"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

For more information on tasks, see Integrate with External Tools via Tasks.

Debugging your code

To enable debugging, you will need to generate a launch.json file:

  • Navigate to the Debug view by clicking the Debug icon in the Sidebar.
  • In the Debug view, click the Configure icon.
  • Select C++ (GDB/LLDB) (to use GDB or LLDB) or C++ (Windows) (to use the Visual Studio Windows Debugger) from the Select Environment dropdown. This creates a launch.json file for editing with two configurations:
    • C++ Launch defines the properties for launching your application when you start debugging.
    • C++ Attach defines the properties for attaching to a process that's already running.
  • Update the program property with the path to the program you are debugging.
  • If you want your application to build when you start debugging, add a preLaunchTask property with the name of the build task you created in tasks.json ("build hello world" in the example above).

Below is an example using the MinGW GDB debugger:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\mingw\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "build hello world"
        }
    ]
}

To learn more, see Configuring launch.json for C/C++ debugging.

If you are debugging with GDB on Windows, see Windows Debugging with GDB.

Editing Code

Code Formatting

The C/C++ extension for Visual Studio Code supports source code formatting using clang-format which is included with the extension.

You can format an entire file with Format Document (Shift+Alt+F) or just the current selection with Format Selection (Ctrl+K Ctrl+F) in right-click context menu. You can also configure auto-formatting with the following settings:

  • C_Cpp.clang_format_formatOnSave - to format when you save your file.
  • editor.formatOnType - to format as you type (triggered on the ; character).

By default, the clang-format style is set to "file" which means it looks for a .clang-format file inside your workspace. If the .clang-format file is found, formatting is applied according to the settings specified in the file. If no .clang-format file is found in your workspace, formatting is applied based on a default style specified in the C_Cpp.clang_format_fallbackStyle setting instead. Currently, the default formatting style is "Visual Studio". Using "Visual Studio" formatting ensures that source code formatting will be compatible in both VS Code and Visual Studio Community.

The "Visual Studio" clang-format style is not yet an official OOTB clang-format style but it implies the following clang-format settings:

UseTab: (VS Code current setting)
IndentWidth: (VS Code current setting)
BreakBeforeBraces: AllMan
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 0

If you'd like to use a different version of clang-format than the one that ships with the extension, you can use the C_Cpp.clang_format_path setting and set its value to the path where the clang-format binary is installed.

For example on the Windows platform:

  "C_Cpp.clang_format_path": "C:\\Program Files (x86)\\LLVM\\bin\\clang-format.exe"

Fuzzy Auto-Complete

Fuzzy auto-complete is powered by an enhanced tag-parser approach. Although suggestions are not based on semantic analysis of your code, this feature provides a wider selection of matches than the single-file IntelliSense experience provided today.

In particular, this feature's capabilities give a good experience for C code.

Navigating Code

The source code navigation features provided by the C/C++ extension are powerful tools for understanding and getting around in your codebase. These features are powered by tags stored in an offline database of symbol information. With the C/C++ extension installed, this database is generated whenever a folder containing C++ source code files is loaded into VS Code. The platform indicator (Win32 in the figure below) turns red and appears next to a flame icon while the tag-parser is generating this information.

The platform indicator during tag parsing

When the platform indicator returns to its normal appearance, the source code symbols have been tagged in the offline database and source code navigation features are ready to be used.

Specifying Additional Include Directories for Better Symbol Support

To provide the best experience, the C/C++ extension for VS Code needs to know where it can find each header file referenced in your code. By default, the extension searches the current source directory, its sub-directories, and some platform-specific locations. If a referenced header file can't be found, VS Code displays a green squiggle underneath each #include directive that references it.

To specify additional include directories to be searched, place your cursor over any #include directive that displays a green squiggle, then click the lightbulb action when it appears. This opens the file c_cpp_properties.json for editing; here you can specify additional include directories for each platform configuration individually by adding more directories to the 'browse.path' property.

Search for Symbols

You can search for symbols in the current file or workspace to navigate your code more quickly.

To search for a symbol in the current file, press Ctrl+Shift+O, then enter the name of the symbol you're looking for. A list of potential matches will appear and be filtered as you type. Choose from the list of matches to navigate to its location.

Searching the current file

To search for a symbol in the current workspace, start by pressing Ctrl+T instead, then enter the name of the symbol. A list of potential matches will appear as before. If you choose a match that was found in a file that's not already open, the file will be opened before navigating to the match's location.

Searching in your workspace

Alternatively, you can search for symbols by accessing these commands through the Command Palette if you prefer. Use Quick Open (Ctrl+P) then enter the '@' command to search the current file, or the '#' command to search the current workspace. Ctrl+Shift+O and Ctrl+T are just shortcuts for the '@' and '#' commands, respectively, so everything works the same.

Peek Definition

You can take a quick look at how a symbol was defined by using the Peek Definition feature. This feature displays a few lines of code near the definition inside a peek window so you can take a look without navigating away from your current location.

To peek at a symbol's definition, place your cursor on the symbol anywhere it's used in your source code and then press Alt+F12. Alternatively, you can choose Peek Definition from the context menu (right-click, then choose Peek Definition).

Peek definition

Currently, the C/C++ extension doesn't parse code in a way that helps it distinguish between competing definitions based on how the symbol is used. These competing definitions arise when the symbol defines different things in different contexts, such as occurs with overloaded functions, classes and their constructors, and other situations. When this happens, each of the competing definitions are listed in the right-hand side of the peek window with the source code of the current selection displayed on the left.

With the peek window open, you browse the list of competing definitions to find the one you're interested in. If you want to navigate to the location of one of the definitions just double-click the definition you're interested in, or by double-clicking anywhere in the source code displayed on the left-hand side of the peek window.

Go to Definition

You can also quickly navigate to where a symbol is defined by using the Go to Definition feature.

To go to a symbol's definition, place your cursor on the symbol anywhere it is used in your source code and then press F12. Alternatively, you can choose Go to Definition from the context menu (right-click, then choose Go to Definition). When there's only one definition of the symbol, you'll navigate directly to its location, otherwise the competing definitions are displayed in a peek window as described in the previous section and you have to choose the definition that you want to go to.

Debugging

After you have set up the basics of your debugging environment as specified in Getting Started, you can learn more details about debugging C/C++ in this section.

VS Code supports the following debuggers for C/C++ depending on the operating system you are using:

  • Linux: GDB
  • macOS: LLDB or GDB
  • Windows: the Visual Studio Windows Debugger or GDB (using Cygwin or MinGW)

Windows Debugging with GDB

You can debug Windows applications created using Cygwin or MinGW by using VS Code. To use Cygwin or MinGW debugging features, the debugger path must be set manually in the launch configuration (launch.json). To debug your Cygwin or MinGW application, add the miDebuggerPath property and set its value to the location of the corresponding gdb.exe for your Cygwin or MinGW environment.

For example:

    "miDebuggerPath": "c:\\mingw\\bin\\gdb.exe"

Cygwin/MinGW debugging on Windows supports both attach and launch debugging scenarios.

Conditional Breakpoints

Conditional breakpoints enable you to break execution on a particular line of code only when the value of the condition is true. To set a conditional breakpoint, right-click on an existing breakpoint and select Edit Breakpoint. This opens a small peek window where you can enter the condition that must evaluate to true in order for the breakpoint to be hit during debugging.

A conditional break

In the editor, conditional breakpoints are indicated by a breakpoint symbol that has a black equals sign inside of it. You can place the cursor over a conditional breakpoint to show its condition.

Function Breakpoints

Function breakpoints enable you to break execution at the beginning of a function instead of on a particular line of code. To set a function breakpoint, on the Debug pane right-click inside the Breakpointssection, then choose Add Function Breakpoint and enter the name of the function on which you want to break execution.

Expression Evaluation

VS Code supports expression evaluation in several contexts:

  • You can type an expression into the Watch section of the Debug panel and it will be evaluated each time a breakpoint is hit.
  • You can type an expression into the Debug Console and it will be evaluated only once.
  • You can evaluate any expression that appears in your code while you're stopped at a breakpoint.

Note that expressions in the Watch section take effect in the application being debugged; an expression that modifies the value of a variable will modify that variable for the duration of the program.

Multi-threaded Debugging

The C/C++ extension for VS Code has the ability to debug multi-threaded programs. All threads and their call stacks appear in the Call Stack section:

Multi-threaded process

Memory Dump Debugging

The C/C++ extension for VS Code also has the ability to debug memory dumps. To debug a memory dump, open your launch.json file and add the coreDumpPath (for GDB or LLDB) or dumpPath (for the Visual Studio Windows Debugger) property to the C++ Launch configuration, set its value to be a string containing the path to the memory dump. This will even work for x86 programs being debugged on an x64 machine.

Additional Symbols

If there are additional directories where the debugger can find symbol files (for example, .pdb files for the Visual Studio Windows Debugger), they can be specified by adding the additionalSOLibSearchPath(for GDB or LLDB) or symbolSearchPath (for the Visual Studio Windows Debugger).

For example:

    "additionalSOLibSearchPath": "/path/to/symbols;/another/path/to/symbols"

or

    "symbolSearchPath": "C:\\path\\to\\symbols;C:\\another\\path\\to\\symbols"

Locate source files

The source file location can be changed if the source files are not located in the compilation location. This is done by simple replacement pairs added in the sourceFileMap section. The first match in this list will be used.

For example:

"sourceFileMap": {
    "/build/gcc-4.8-fNUjSI/gcc-4.8-4.8.4/build/i686-linux-gnu/libstdc++-v3/include/i686-linux-gnu": "/usr/include/i686-linux-gnu/c++/4.8",
    "/build/gcc-4.8-fNUjSI/gcc-4.8-4.8.4/build/i686-linux-gnu/libstdc++-v3/include": "/usr/include/c++/4.8"
}

GDB, LLDB and MI Commands (GDB/LLDB)

For the C++ (GDB/LLDB) debugging environment, you can execute GDB, LLDB and MI commands directly through the debug console with the -exec command, but be careful, executing commands directly in the debug console is untested and might crash VS Code in some cases.

Other Debugging Features

  • Unconditional breakpoints
  • Watch window
  • Call stack
  • Stepping

For more information on debugging with VS Code, see this introduction to debugging in VS Code.

Known Limitations

Symbols and Code Navigation

All platforms:

  • Because the extension doesn't parse function bodies, Peek Definition and Go to Definition don't work for symbols defined inside the body of a function.

Debugging

Windows:

  • GDB on Cygwin and MinGW cannot break a running process. To set a breakpoint when the application is running (not stopped under the debugger), or to pause the application being debugged, press Ctrl-C in the application's terminal.
  • GDB on Cygwin cannot open core dumps.

Linux:

  • GDB needs elevated permissions to attach to a process. When using attach to process, you need to provide your password before the debugging session can begin.

macOS:

  • LLDB:
    • When debugging with LLDB, if the Terminal window is closed while in break mode, debugging does not stop. Debugging can be stopped by pressing the Stop button.
    • When debugging is stopped the Terminal window is not closed.
  • GDB:
    • Additional manual install steps need to be completed to use GDB on macOS. See Manual Installation of GDB for OS X in the README.
    • When attaching to a process with GDB, the application being debugged cannot be interrupted. GDB will only bind breakpoints set while the application is not running (either before attaching to the application, or while the application is in a stopped state). This is due to a bug in GDB.
    • Core dumps cannot be loaded when debugging with GDB because GDB does not support the core dump format used in macOS.
    • When attached to a process with GDB, break-all will end the process.

Next Steps

Read on to find out about:

  • Basic Editing - Learn about the powerful VS Code editor.
  • Code Navigation - Move quickly through your source code.
  • Tasks - use tasks to build your project and more
  • Debugging - find out how to use the debugger with your project

Common Questions

Q: My project won't load.

A: VS Code doesn't currently support C++ project files, instead it considers a directory of your choosing to be the workspace of your project. Source code files inside that directory and its sub-directories are part of the workspace.

Q: How do I build/run my project?

A: VS Code supports tasks that you can configure to build your application, and natively understands the output of MSBuild, CSC, and XBuild. For more information, see the Tasks documentation.

If you have any other questions or run into any issues, please file an issue on GitHub.

2018/03/07 15:02 2018/03/07 15:02

Posted on 2018/03/07 13:09
Filed Under Linux/장애처리

DNS server, DNS service  

Ubuntu 16.04에서, 
apt-get install 로 package 설치시,

해당 패키지에 접근할 수 없다는 오류

E: Failed to fetch  '패키지 이름' 403  Forbidden

가 발생시, 
간단하게

다음과 같이 해결 할 수 있다.

우선 /etc/appt/sources.list 파일을 백업 한후,

기존 sources.list 내용을 지우고 다음과 같이 2줄을 추가.

more..



하고 다시

apt-get update 를 해주면 정상적으로 package가 설치됨.

2018/03/07 13:09 2018/03/07 13:09

Posted on 2018/02/05 21:54
Filed Under Linux/설정방법

DNS server, DNS service  


출처 : http://egloos.zum.com/mcchae/v/11263102

Mac 에서 (Sierra) static route를 설정할 필요가 있습니다.
예를 들어,
Wi-Fi 로 연결된 자신의 주소가 192.168.10.100 이었고,
192.168.10.200 이라는 내부 라우터가
192.168.100.0/24 네트워크를 라우팅할 필요가 있다면
터미널에서
$ sudo route -n add 192.168.100.0/24 192.168.10.200
라고 명령을 주면 됩니다.
문제는 다음에 재기동하면 다시 이 정보가 없어지는 문제가 있지요.
다음은 간단히 networksetup 명령을 이용하여 static routing 정보를
시스템에 등록하는 방법입니다.
우선 현재 시스템에 설치된 인터페이스를 검색합니다.
$ networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
Wi-Fi
USB 10/100/1000 LAN
iPhone USB
Bluetooth PAN
Thunderbolt Bridge
Wi-Fi 인터페이스에 지정된 정보를 확인합니다.
$ networksetup -getinfo Wi-Fi
DHCP Configuration
IP address: 192.168.10.160
Subnet mask: 255.255.255.0
Router: 192.168.10.1
Client ID:
IPv6: Automatic
IPv6 IP address: none
IPv6 Router: none
Wi-Fi ID: 80:e6:50:0f:1a:f4
혹시 이전에 설정한 static 정보가 있는지 확인합니다.
$ networksetup -getadditionalroutes Wi-Fi
There are no additional IPv4 routes on Wi-Fi.
 
이제는 위에서 설명한 것과 같은 static 라우팅 정보를 지정합니다.
$ sudo networksetup -setadditionalroutes Wi-Fi 192.168.100.0 255.255.255.0 192.168.10.200
다시 부팅을 하거나 해도 다음과 같이 정적 라우팅 정보를 확인해 보면,
$ networksetup -getadditionalroutes Wi-Fi
192.168.100.0 255.255.255.0 192.168.10.200
과 같이 정적 라우팅이 지정됩니다.
2018/02/05 21:54 2018/02/05 21:54

Posted on 2018/01/22 18:24
Filed Under Linux/장애처리

DNS server, DNS service  

DSM 6.2 업데이트 이전에는 잘되던 SSH가 갑지가 6.2 업데이트 후 SSH 접속이 되지 않을 경우,

다음에 따라 수정할 것.

1. telnet 활성화.
2. telnet 을 통해 admin 계정 접속 후,
3. 다음의 파일 수정
  파일 : /etc/ssh/sshd_config
ChallengeResponseAuthentication 는 yes
UsePAM 는 no
로 변경 후,

저장
4. SSH 재시작
  명령어 : killall -1 sshd

이후 SSH 가 접속되는 것을 확인 후 telnet은 비활성화
2018/01/22 18:24 2018/01/22 18:24

Posted on 2017/10/19 17:43
Filed Under Embedded/최적화 및 팁

DNS server, DNS service  

below are the commands u can execute and also more u can play

windsh [windsh]
NAME
windsh [windsh] - The Tornado Shell 

ROUTINES

agentModeShow( ) - show the agent mode (*) (WindSh)
b( ) - set or display breakpoints (WindSh)
bd( ) - delete a breakpoint (WindSh)
bdall( ) - delete all breakpoints (WindSh)
bh( ) - set a hardware breakpoint (WindSh)
bootChange( ) - change the boot line (WindSh)
browse( ) - send a message to the browser asking it to browse an
address (*) (WindSh)
c( ) - continue from a breakpoint (WindSh)
cd( ) - change the default directory (WindSh) 
checkStack( ) - print a summary of each task's stack usage (WindSh)
classShow( ) - show information about a class of objects (*) (WindSh)
cplusCtors( ) - call static constructors (C++) (WindSh)
cplusDtors( ) - call static destructors (C++) (WindSh)
cplusStratShow( ) - show C++ static constructors calling strategy (*) (WindSh)
cplusXtorSet( ) - change C++ static constructor calling strategy (C++) (WindSh)
cret( ) - continue until the current subroutine returns (WindSh)
d( ) - display memory (WindSh)
devs( ) - list all system-known devices (WindSh)
h( ) - display or set the size of shell history (WindSh)
help( ) - print a synopsis of selected routines (WindSh)
hostShow( ) - display the host table (WindSh)
i( ) - print a summary of each task's TCB, task by task (WindSh)
iStrict( ) - print a summary of all task TCBs, as an atomic snapshot (*) (WindSh)
icmpstatShow( ) - display statistics for ICMP (WindSh)
ifShow( ) - display the attached network interfaces (WindSh)
inetstatShow( ) - display all active connections for Internet protocol sockets (WindSh)
intVecShow( ) - display the interrupt vector table (WindSh)
iosDevShow( ) - display the list of devices in the system (WindSh)
iosDrvShow( ) - display a list of system drivers (WindSh)
iosFdShow( ) - display a list of file descriptor names in the system (WindSh)
ipstatShow( ) - display IP statistics (WindSh)
l( ) - disassemble and display a specified number of instructions (WindSh)
ld( ) - load an object module into memory (WindSh)
lkAddr( ) - list symbols whose values are near a specified value (WindSh)
lkup( ) - list symbols (WindSh)
ls( ) - list the contents of a directory (WindSh)
m( ) - modify memory (WindSh)
memPartShow( ) - show partition blocks and statistics (WindSh)
memShow( ) - show system memory partition blocks and statistics (WindSh)
moduleIdFigure( ) - figure out module ID, given name or number (*) (WindSh)
moduleShow( ) - show the current status for all the loaded modules (WindSh)
mqPxShow( ) - show information about a POSIX message queue (*) (WindSh)
mRegs( ) - modify registers (WindSh)
msgQShow( ) - show information about a message queue (WindSh)
period( ) - spawn a task to call a function periodically (WindSh)
printErrno( ) - print the definition of a specified error status value (WindSh)
printLogo( ) - display the Tornado logo (WindSh)
pwd( ) - display the current default directory (WindSh)
quit( ) - shut down WindSh (*) (WindSh)
reboot( ) - reset network devices and transfer control to boot ROMs (WindSh)
repeat( ) - spawn a task to call a function repeatedly (WindSh)
routestatShow( ) - display routing statistics (WindSh)
s( ) - single-step a task (WindSh)
semPxShow( ) - show information about a POSIX semaphore (*) (WindSh)
semShow( ) - show information about a semaphore (WindSh)
shellHistory( ) - display or set the size of shell history (WindSh)
shellPromptSet( ) - change the shell prompt (WindSh)
show( ) - display information on a specified object (WindSh)
smMemPartShow( ) - show user's shared memory system partition blocks and statistics (*) (WindSh)
smMemShow( ) - show the shared memory system partition blocks and statistics (WindSh)
so( ) - single-step, but step over a subroutine (WindSh)
sp( ) - spawn a task with default parameters (WindSh)
sps( ) - spawn a task with default parameters, and leave it suspended (*) (WindSh)
sysResume( ) - reset the agent to tasking mode (*) (WindSh)
sysStatusShow( ) - show system context status (*) (WindSh)
sysSuspend( ) - set the agent to external mode and suspend the system (*) (WindSh)
taskCreateHookShow( ) - show the list of task create routines (WindSh)
taskDeleteHookShow( ) - show the list of task delete routines (WindSh)
taskIdDefault( ) - set the default task ID (WindSh)
taskIdFigure( ) - figure out the task ID of a specified task (*) (WindSh)
taskRegsShow( ) - display the contents of a task's registers (WindSh)
taskShow( ) - display task information from TCBs (WindSh)
taskSwitchHookShow( ) - show the list of task switch routines (WindSh)
taskWaitShow( ) - show information about the object a task is pended on (*) (WindSh)
tcpstatShow( ) - display all statistics for the TCP protocol (WindSh)
td( ) - delete a task (WindSh)
tftpInfoShow( ) - get TFTP status information (WindSh)
ti( ) - display complete information from a task's TCB (WindSh)
tr( ) - resume a task (WindSh)
ts( ) - suspend a task (WindSh)
tt( ) - display a stack trace of a task (WindSh)
tw( ) - print info about the object the given task is pending on (*) (WindSh)
udpstatShow( ) - display statistics for the UDP protocol (WindSh)
unld( ) - unload an object module by specifying a file name or module ID (WindSh)
version( ) - print VxWorks version information (WindSh)
w( ) - print a summary of each task's pending information, task by task (*) (WindSh)
wdShow( ) - show information about a watchdog (WindSh)

for more details inside your tornado installation, go to
docs->tornado->tools->windsh.html
2017/10/19 17:43 2017/10/19 17:43
TAG :

Posted on 2017/08/17 23:12
Filed Under Programming/Database

DNS server, DNS service  

mysql 데이터베이스 생성 및 사용자 추가 
<mysql 접속>

# mysql -u root -p
root 패스워드 치고 접속


<데이터베이스 목록 확인>

mysql> show databases;
+--------------------+
| Database                |
+--------------------+
| information_schema |
| mysql                     |
+--------------------+
2 rows in set (0.00 sec)


<test 데이터베이스 생성>

mysql> create database test;


<데이터 생성되었는지 확인>

mysql> show databases;
+--------------------+
| Database                |
+--------------------+
| information_schema |
| mysql                     |
| test                        |
+--------------------+
3 rows in set (0.00 sec)


<사용자 추가하고 생성한 데이터베이스 사용 권한 주기>

grant all privileges on test.* to testuser@localhost identified by 'testuser 계정의 패스워드 입력' with grant option;


<testuser 사용자 생성되었는지 확인>

mysql> use mysql;
mysql> select * from user;     <- 이건 전체 유저 확인
mysql> select * from user where user='testuser';     <- 이건 testuser 계정 확인
<DataBase 삭제 >

mysql> drop database test;


<testuser 사용자 삭제>

mysql> delete from user where user='testuser';
2017/08/17 23:12 2017/08/17 23:12

Posted on 2017/08/15 21:02
Filed Under Programming/Tools

DNS server, DNS service  

Synology NAS에서의 작업 
1. 제어판에서 SSH 활성화
2. 제어판에서 "사용자 홈 서비스 활성화"
3. 제어판에서 git을 사용할 사용자의 homes 권한은 "읽기/쓰기" 권한을 부여
4. 패키지 센터에서 "Git Server"을 다운로드.
5. "Git Server"을 실행후, git 을 사용할 사용자에게 권한을 부여
Synology NAS - SSH로 접속 후, root 로그인 

cd..
cd volumes1/homes/gituser (Git 사용자)
mkdir project.git   (Git 프로젝트 폴더)
cd project.git
git init --bare --shared
git update-server-info
cd..
chown -R gituser:users project.git (권한을 Git 유저에게 부여)
ls -al (권한이 제대로 옮겨졌는지 확인)

이후 원격지에서 Synology NAS GIT 서버에 리포지토리로 추가하는 방법.

mkdir project.git (원격지의 Git 프로젝트(리포지토리)생성)
cd project.git
git init
git remote add origin ssh://gituser@시놀로지IP:포트/volume1/homes/gituser/project.git (Git 폴더)
2017/08/15 21:02 2017/08/15 21:02

Posted on 2017/07/07 15:02
Filed Under Linux/설정방법

DNS server, DNS service  

1. vmware tool 설치
  (open-vm-tools)

2. shrink 실행 
// 명령어 확인
# vmware-toolbox-cmd help disk
// shrink할 대상 list 확인
# vmware-toolbox-cmd disk list
// shrink 실행
# vmware-toolbox-cmd disk shrink 디스크명
2017/07/07 15:02 2017/07/07 15:02
TAG :

Posted on 2017/07/04 10:54
Filed Under Linux/장애처리

DNS server, DNS service  

1. MySQL 서버 정지.

/etc/init.d/mysql stop

2. MySQL 삭제


apt-get remove dbconfig-mysql
apt-get purge mysql*
apt-get autoremove
apt-get autoclean

3. MySQL 데이터 디렉토리 삭제
rm -rfv /etc/mysql /var/lib/mysql

4. MySQL 서버 설치
apt-get upgrade
apt-get dist-upgrade
apt-get install mysql-server
2017/07/04 10:54 2017/07/04 10:54

Posted on 2017/03/24 16:17
Filed Under Programming/C#

DNS server, DNS service  

윈도우 7 64Bit 이상부터는, 더 이상 시스템의 내장 스피커를 이용하여 비프음을 낼 수 없다고 한다. (윈도우 API에서 더 이상 지원하지 않음)

그러나 아래 링크와 같이 시스템에 직접 접근해서 가능하다.

링크 : https://www.codeproject.com/Tips/1022207/Make-Buzzer-Internal-Speaker-Sound-in-Windows-bit

링크 캡쳐 (원문의 링크가 없어져 더이상 보기 어려울 경우를 대비)

사용자 삽입 이미지


2017/03/24 16:17 2017/03/24 16:17

Posted on 2015/11/12 10:44
Filed Under Programming/C#

DNS server, DNS service  

C#으로 짠 또다른 프로그램(other.exe)을 실행하기위해서

 

System.Diagnostics.Process proc = System.Diagnostics.Process.Start("./other.exe");

 

 

 

종료

 

public const int WM_SYSCOMMAND = 0x0112;

public const int SC_CLOSE = 0xF060;

 

[DllImport("user32.dll")]

public static extern int FindWindow(

    string lpClassName, // class name

    string lpWindowName // window name

);

 

[DllImport("user32.dll")]

public static extern int SendMessage(

    int hWnd, // handle to destination window

    uint Msg, // message

    int wParam, // first message parameter

    int lParam // second message parameter

);

 

 

1. FindWindows로 창핸들을 찾아온다

 

int iHandle=Win32.FindWindow(className ,txtWndNm.Text);

2. SendMessage로 클로즈메세지를 보낸다.

 

int j=Win32.SendMessage(iHandle, Win32.WM_SYSCOMMAND,Win32.SC_CLOSE, 0);

 

Process.Kill()을 했는데도 안죽은게 이상하긴 하지만 위와 같이 사용하시면 확실히 죽을겁니다.

또한 외부 프로그램에 Message를 던질수도 있습니다.

2015/11/12 10:44 2015/11/12 10:44

Posted on 2015/11/05 11:26
Filed Under Programming/C#

DNS server, DNS service  

관리자 권한이 없는 상태에서 시스템의 정보를 읽거나 쓰려고 할때 프로그램이 올바르게 작동하지 않습니다. 이럴때 프로그램이 실행되면서, 관리자 권한으로 상승시키는 것이 필요한데요. C#에서 이러한 내용에 대한 코드를 정리합니다. 모든 코드는 Program.cs에서 이루어집니다. 먼저 using 절에 다음과 같은 네임스페이스를 추가합니다.




using System.Security.Principal;
using System.Diagnostics; 


그리고 현재 관리자 권한 상태인지의 여부를 파악하는 함수를 추가합니다.


public static bool IsAdministrator()
{
    WindowsIdentity identity = WindowsIdentity.GetCurrent();
 
    if (null != identity)
    {
        WindowsPrincipal principal = new WindowsPrincipal(identity);
        return principal.IsInRole(WindowsBuiltInRole.Administrator);
    }
 
    return false;


Program.cs 파일의 Main 함수의 시작 부분에 다음의 코드를 추가하여 관리자 권한으로 실행되는지를 확인 한다.


            if (IsAdministrator() == false)
            {
                try
                {
                    ProcessStartInfo procInfo = new ProcessStartInfo();
                    procInfo.UseShellExecute = true;
                    procInfo.FileName = "IPSwitcher";
                    procInfo.WorkingDirectory = Environment.CurrentDirectory;
                    procInfo.Verb = "runas";
                    Process.Start(procInfo);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("This Program need to Administrator Authority:" + ex.Message);
                }
                return;
            }
 
2015/11/05 11:26 2015/11/05 11:26

Posted on 2015/11/02 09:59
Filed Under Windows/장애처리

DNS server, DNS service  

SVN 클라이언트중에 TortoiseSVN 만한 것이 없어, 잘 사용하고 있는데

언젠가 부터 윈도우 탐색기에 아이콘 표시가 나타나지 않는다..
아이콘이 안보이면 무척 불편해서..

확인해보니, Explorer에서 오버레이가 10개까지 지원되는데, Explorer Shell 에서 아이콘 오버레이 우선 순위가 밀려서 나타나지 않는것..

수정 방법
1. regedit 실행
2. 다음의 레지스트리 키위치로 이동 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers 
3. 2번 키의 자식 폴더에 tortoiseXXXXX 앞에 공백을 추가하여 우선 순위를 올려준다.
4. 탐색기 다시 시작하거나 윈도 리부팅

사용자 삽입 이미지
2015/11/02 09:59 2015/11/02 09:59

Posted on 2015/09/30 10:11
Filed Under Windows/장애처리

DNS server, DNS service  

1. 명령프롬프트 실행 (관리자 권한)
2. "net start vmx86" 입력
2015/09/30 10:11 2015/09/30 10:11

Posted on 2015/06/08 13:53
Filed Under Windows/최적화 및 팁

DNS server, DNS service  

원문 : https://msdn.microsoft.com/ko-kr/library/dn251565.aspx

WinSxS 폴더 정리

일반적인 질문 중 하나는 일부 디스크 공간을 다시 얻기 위해 WinSxS 폴더를 삭제할 수 있는가 하는 것입니다. 간단한 대답은 아니요입니다. 하지만 WinSxS 폴더 크기를 줄일 수 있는 방법이 있습니다. WinSxS 폴더에 대한 자세한 내용은 구성 요소 저장소 관리를 참조하세요. 이 항목에서는 실행 중인 Windows 8.1 버전에서 WinSxS 폴더 크기를 줄이는 다양한 방법에 대해 설명합니다.

Windows 8.1 및 Windows Server 2012 R2에서는 이 항목에 설명된 방법과 유사한 방법을 사용하여 WinSxS 크기를 자동으로 줄이지만 이러한 방법에는 최신 버전에서 다른 구성 요소로 대체된 구성 요소가 포함된 패키지를 제거하고 삭제하는 등의 내부 프로세스가 포함됩니다. 이전 버전의 일부 구성 요소는 필요한 경우 롤백할 수 있도록 일정 기간 동안 시스템에서 유지됩니다. 일정 기간 후에 이러한 구성 요소는 설치에서 제거됩니다.

오프라인 Windows 이미지에서 구성 요소 저장소 크기 줄이기에 설명된 대로 몇 가지 동일한 기술을 사용하여 Windows 이미지의 크기를 줄일 수도 있습니다.

Warning경고
WinSxS 폴더에서 파일을 삭제하거나 전체 WinSxS 폴더를 삭제하면 시스템이 심각하게 손상되어 PC가 부팅되지 않고 PC를 업데이트하지 못할 수 있습니다.

 

 

Windows 8.1 및 Windows Server 2012 R2에서는 패키지 삭제와 구성 요소 압축을 사용하여 WinSxS 폴더를 정리하는 구성 요소 저장소 정리를 시작하는 다양한 방법이 있습니다.

StartComponentCleanup 작업은 Windows 8에서 만들어지고 시스템이 사용되지 않을 때 자동으로 구성 요소를 정기적으로 정리합니다. 이 작업은 운영 체제에서 트리거할 때 자동으로 실행되도록 설정되어 있습니다. 자동으로 실행될 경우 이 작업은 이전 버전의 구성 요소를 제거하기 전에 업데이트된 구성 요소가 설치된 후 30일 이상 대기합니다.

이 작업을 실행하도록 선택하면 작업에 시간 제한 1시간이 제공되며 모든 파일이 완벽하게 정리되지 않을 수 있습니다.

  1. 작업 스케줄러가 열려 있지 않으면 작업 스케줄러를 시작합니다. 자세한 내용은 작업 스케줄러 시작을 참조하세요.

  2. 콘솔 트리를 확장하고 Task Scheduler Library\Microsoft\Windows\Servicing\StartComponentCleanup으로 이동합니다.

  3. 선택한 항목에서 실행을 클릭합니다.

note참고
StartComponentCleanup 작업을 명령줄에서 시작할 수도 있습니다.

 

schtasks.exe /Run /TN "\Microsoft\Windows\Servicing\StartComponentCleanup"

 

 

DISM(배포 이미지 서비스 및 관리)은 Windows 기능, 패키지, 드라이버 및 국가별 설정을 설치, 제거, 구성 및 업데이트하는 데 사용할 수 있는 명령줄 도구입니다. Dism.exe의 /Cleanup-Image 매개 변수는 고급 사용자에게 WinSxS 폴더 크기를 추가로 줄일 수 있는 더 많은 옵션을 제공합니다. 자세한 내용은 DISM 운영 체제 패키지 서비스 명령줄 옵션을 참조하세요.

  1. 실행 중인 Windows 8.1 버전에서 Dism.exe의 /StartComponentCleanup 매개 변수는 업데이트된 구성 요소의 이전 버전이 즉시 삭제되고(30일 유예 기간 없이) 시간 제한 1시간이 없다는 점을 제외하고 작업 스케줄러에서 StartComponentCleanup 작업을 실행한 것과 유사한 결과를 제공합니다.

    관리자 권한 명령 프롬프트에 다음과 같이 입력합니다.

    Dism.exe /online /Cleanup-Image /StartComponentCleanup
    
  1. 실행 중인 Windows 8.1 버전에서 /ResetBase 스위치를 DISM의 /StartComponentCleanup 매개 변수와 함께 사용하면 구성 요소 저장소에 있는 모든 구성 요소의 모든 교체된 버전이 제거됩니다.

    관리자 권한 명령 프롬프트에 다음과 같이 입력합니다.

    Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
    
    Warning경고
    이 명령이 완료된 후에는 일부 기존 서비스 팩 및 업데이트를 제거할 수 없습니다. 이로 인해 이후 서비스 팩 또는 업데이트의 제거가 차단되지 않습니다.

     

     

  1. 서비스 팩에 사용되는 공간 크기를 줄이려면 실행 중인 Windows 8.1 버전에서 Dism.exe의 /SPSuperseded 매개 변수를 사용하여 서비스 팩 제거에 필요한 모든 백업 구성 요소를 제거합니다. 서비스 팩은 특정 Windows 버전에 대한 누적 업데이트 모음입니다.

    관리자 권한 명령 프롬프트에 다음과 같이 입력합니다.

    Dism.exe /online /Cleanup-Image /SPSuperseded
    
    Warning경고
    이 명령이 완료된 후에는 서비스 팩을 제거할 수 없습니다.

     

     

디스크 정리를 사용하여 드라이브에서 필요 없는 파일 수를 줄이면 PC가 더 빨리 실행되도록 할 수 있습니다. 그러면 임시 파일 및 시스템 파일이 삭제되고, 휴지통이 비워지며, 더 이상 필요하지 않은 여러 가지 기타 항목들이 제거됩니다. 업데이트를 정리하는 옵션은 구성 요소 저장소 크기를 줄이는 데 도움이 됩니다.

  1. 시스템 파일을 삭제하려면 디스크 정리를 사용하여 파일 삭제에 제공된 단계를 실행합니다.

2015/06/08 13:53 2015/06/08 13:53

About

by CoCo

Notice

Counter

· Total
: 854500
· Today
: 7
· Yesterday
: 67